static int auth_init_group(struct wpa *wpa) { struct wpa_auth_config conf; struct wpa_auth_callbacks cb; wpa_printf(MSG_DEBUG, "AUTH: Initializing group state machine"); os_memset(&conf, 0, sizeof(conf)); conf.wpa = 2; conf.wpa_key_mgmt = WPA_KEY_MGMT_PSK; conf.wpa_pairwise = WPA_CIPHER_CCMP; conf.rsn_pairwise = WPA_CIPHER_CCMP; conf.wpa_group = WPA_CIPHER_CCMP; conf.eapol_version = 2; os_memset(&cb, 0, sizeof(cb)); cb.ctx = wpa; cb.logger = auth_logger; cb.send_eapol = auth_send_eapol; cb.get_psk = auth_get_psk; wpa->auth_group = wpa_init(wpa->auth_addr, &conf, &cb); if (wpa->auth_group == NULL) { wpa_printf(MSG_DEBUG, "AUTH: wpa_init() failed"); return -1; } return 0; }
static int ibss_rsn_auth_init_group(struct ibss_rsn *ibss_rsn, const u8 *own_addr) { struct wpa_auth_config conf; struct wpa_auth_callbacks cb; wpa_printf(MSG_DEBUG, "AUTH: Initializing group state machine"); os_memset(&conf, 0, sizeof(conf)); conf.wpa = 2; conf.wpa_key_mgmt = WPA_KEY_MGMT_PSK; conf.wpa_pairwise = WPA_CIPHER_CCMP; conf.rsn_pairwise = WPA_CIPHER_CCMP; conf.wpa_group = WPA_CIPHER_CCMP; conf.eapol_version = 2; conf.wpa_group_rekey = 600; os_memset(&cb, 0, sizeof(cb)); cb.ctx = ibss_rsn; cb.logger = auth_logger; cb.send_eapol = auth_send_eapol; cb.get_psk = auth_get_psk; cb.set_key = auth_set_key; cb.for_each_sta = auth_for_each_sta; ibss_rsn->auth_group = wpa_init(own_addr, &conf, &cb); if (ibss_rsn->auth_group == NULL) { wpa_printf(MSG_DEBUG, "AUTH: wpa_init() failed"); return -1; } return 0; }
static int hostapd_setup_interface(hostapd *hapd) { if (hostapd_driver_init(hapd)) { printf("Host AP driver initialization failed.\n"); return -1; } printf("Using interface %sap with hwaddr " MACSTR " and ssid '%s'\n", hapd->conf->iface, MAC2STR(hapd->own_addr), hapd->conf->ssid); /* Set SSID for the kernel driver (to be used in beacon and probe * response frames) */ if (hostap_ioctl_setiwessid(hapd->driver.data, hapd->conf->ssid, hapd->conf->ssid_len)) { printf("Could not set SSID for kernel driver\n"); return -1; } if (radius_client_init(hapd)) { printf("RADIUS client initialization failed.\n"); return -1; } if (hostapd_acl_init(hapd)) { printf("ACL initialization failed.\n"); return -1; } if (ieee802_1x_init(hapd)) { printf("IEEE 802.1X initialization failed.\n"); return -1; } if (hapd->conf->wpa && wpa_init(hapd)) { printf("WPA initialization failed.\n"); return -1; } if (accounting_init(hapd)) { printf("Accounting initialization failed.\n"); return -1; } if (hapd->conf->ieee802_11f && iapp_init(hapd)) { printf("IEEE 802.11f (IAPP) initialization failed.\n"); return -1; } if (hostapd_wireless_event_init(hapd->driver.data) < 0) return -1; if (hapd->default_wep_key && hostapd_setup_encryption(hapd)) return -1; if (hostapd_flush_old_stations(hapd)) return -1; return 0; }
static int __mesh_rsn_auth_init(struct mesh_rsn *rsn, const u8 *addr) { struct wpa_auth_config conf; struct wpa_auth_callbacks cb; u8 seq[6] = {}; wpa_printf(MSG_DEBUG, "AUTH: Initializing group state machine"); os_memset(&conf, 0, sizeof(conf)); conf.wpa = 2; conf.wpa_key_mgmt = WPA_KEY_MGMT_SAE; conf.wpa_pairwise = WPA_CIPHER_CCMP; conf.rsn_pairwise = WPA_CIPHER_CCMP; conf.wpa_group = WPA_CIPHER_CCMP; conf.eapol_version = 0; conf.wpa_group_rekey = -1; os_memset(&cb, 0, sizeof(cb)); cb.ctx = rsn; cb.logger = auth_logger; cb.get_psk = auth_get_psk; cb.set_key = auth_set_key; cb.start_ampe = auth_start_ampe; rsn->auth = wpa_init(addr, &conf, &cb); if (rsn->auth == NULL) { wpa_printf(MSG_DEBUG, "AUTH: wpa_init() failed"); return -1; } /* TODO: support rekeying */ if (random_get_bytes(rsn->mgtk, 16) < 0) { wpa_deinit(rsn->auth); return -1; } /* group mgmt */ wpa_drv_set_key(rsn->wpa_s, WPA_ALG_IGTK, NULL, 4, 1, seq, sizeof(seq), rsn->mgtk, sizeof(rsn->mgtk)); /* group privacy / data frames */ wpa_drv_set_key(rsn->wpa_s, WPA_ALG_CCMP, NULL, 1, 1, seq, sizeof(seq), rsn->mgtk, sizeof(rsn->mgtk)); return 0; }
static int ibss_rsn_auth_init_group(struct ibss_rsn *ibss_rsn, const u8 *own_addr, struct wpa_ssid *ssid) { struct wpa_auth_config conf; static const struct wpa_auth_callbacks cb = { .logger = auth_logger, .set_eapol = auth_set_eapol, .send_eapol = auth_send_eapol, .get_psk = auth_get_psk, .set_key = auth_set_key, .for_each_sta = auth_for_each_sta, .disconnect = ibss_rsn_disconnect, }; wpa_printf(MSG_DEBUG, "AUTH: Initializing group state machine"); os_memset(&conf, 0, sizeof(conf)); conf.wpa = 2; conf.wpa_key_mgmt = WPA_KEY_MGMT_PSK; conf.wpa_pairwise = WPA_CIPHER_CCMP; conf.rsn_pairwise = WPA_CIPHER_CCMP; conf.wpa_group = WPA_CIPHER_CCMP; conf.eapol_version = 2; conf.wpa_group_rekey = ssid->group_rekey ? ssid->group_rekey : 600; conf.wpa_group_update_count = 4; conf.wpa_pairwise_update_count = 4; ibss_rsn->auth_group = wpa_init(own_addr, &conf, &cb, ibss_rsn); if (ibss_rsn->auth_group == NULL) { wpa_printf(MSG_DEBUG, "AUTH: wpa_init() failed"); return -1; } wpa_init_keys(ibss_rsn->auth_group); return 0; }
int hostapd_setup_wpa(struct hostapd_data *hapd) { struct wpa_auth_config _conf; struct wpa_auth_callbacks cb; const u8 *wpa_ie; size_t wpa_ie_len; hostapd_wpa_auth_conf(hapd->conf, &_conf); if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_EAPOL_TX_STATUS) _conf.tx_status = 1; os_memset(&cb, 0, sizeof(cb)); cb.ctx = hapd; cb.logger = hostapd_wpa_auth_logger; cb.disconnect = hostapd_wpa_auth_disconnect; cb.mic_failure_report = hostapd_wpa_auth_mic_failure_report; cb.set_eapol = hostapd_wpa_auth_set_eapol; cb.get_eapol = hostapd_wpa_auth_get_eapol; cb.get_psk = hostapd_wpa_auth_get_psk; cb.get_msk = hostapd_wpa_auth_get_msk; cb.set_key = hostapd_wpa_auth_set_key; cb.get_seqnum = hostapd_wpa_auth_get_seqnum; cb.send_eapol = hostapd_wpa_auth_send_eapol; cb.for_each_sta = hostapd_wpa_auth_for_each_sta; cb.for_each_auth = hostapd_wpa_auth_for_each_auth; cb.send_ether = hostapd_wpa_auth_send_ether; #ifdef CONFIG_IEEE80211R cb.send_ft_action = hostapd_wpa_auth_send_ft_action; cb.add_sta = hostapd_wpa_auth_add_sta; #endif /* CONFIG_IEEE80211R */ hapd->wpa_auth = wpa_init(hapd->own_addr, &_conf, &cb); if (hapd->wpa_auth == NULL) { wpa_printf(MSG_ERROR, "WPA initialization failed."); return -1; } if (hostapd_set_privacy(hapd, 1)) { wpa_printf(MSG_ERROR, "Could not set PrivacyInvoked " "for interface %s", hapd->conf->iface); return -1; } wpa_ie = wpa_auth_get_wpa_ie(hapd->wpa_auth, &wpa_ie_len); if (hostapd_set_generic_elem(hapd, wpa_ie, wpa_ie_len)) { wpa_printf(MSG_ERROR, "Failed to configure WPA IE for " "the kernel driver."); return -1; } if (rsn_preauth_iface_init(hapd)) { wpa_printf(MSG_ERROR, "Initialization of RSN " "pre-authentication failed."); return -1; } #ifdef CONFIG_IEEE80211R if (!hostapd_drv_none(hapd)) { hapd->l2 = l2_packet_init(hapd->conf->bridge[0] ? hapd->conf->bridge : hapd->conf->iface, NULL, ETH_P_RRB, hostapd_rrb_receive, hapd, 1); if (hapd->l2 == NULL && (hapd->driver == NULL || hapd->driver->send_ether == NULL)) { wpa_printf(MSG_ERROR, "Failed to open l2_packet " "interface"); return -1; } } #endif /* CONFIG_IEEE80211R */ return 0; }
/*! * @brief Setup hardware. * * Write some registry settings to the device hardware. * WiFiEngine_Plug() must be called before calling this function. * * @param test_mode TRUE if it's a rf test firmware running, FALSE if * it's a regular firmware * * @retval WIFI_ENGINE_SUCCESS */ int WiFiEngine_Configure_Device(int test_mode) { rGeneralWiFiProperties* generalWiFiProperties; rBasicWiFiProperties* basic; basic = (rBasicWiFiProperties*)Registry_GetProperty(ID_basic); generalWiFiProperties = (rGeneralWiFiProperties*)Registry_GetProperty(ID_general); we_wlp_configure_device(); /* this should come ~first */ /* Set the MAC address from registry unless it is 0xffffffff */ if (! wei_is_bssid_bcast(generalWiFiProperties->macAddress)) { WiFiEngine_SendMIBSet(MIB_dot11MACAddress, NULL, generalWiFiProperties->macAddress.octet, sizeof(generalWiFiProperties->macAddress.octet)); } else { wei_get_mib_with_update(MIB_dot11MACAddress, generalWiFiProperties->macAddress.octet, sizeof generalWiFiProperties->macAddress.octet, NULL, WE_IND_NOOP); } wei_rate_configure(); if(test_mode) { /* let's leave it at this */ return WIFI_ENGINE_SUCCESS; } #if (DE_AGGREGATE_HI_DATA == CFG_AGGR_ALL) wei_enable_aggregation(AGGR_ALL, DE_HI_MAX_SIZE); #elif (DE_AGGREGATE_HI_DATA == CFG_AGGR_SCAN_IND) wei_enable_aggregation(AGGR_SCAN_IND, DE_HI_MAX_SIZE); #elif (DE_AGGREGATE_HI_DATA == CFG_AGGR_ALL_BUT_DATA) wei_enable_aggregation(AGGR_ALL_BUT_DATA, DE_HI_MAX_SIZE); #elif (DE_AGGREGATE_HI_DATA == CFG_AGGR_ONLY_DATA_CFM) wei_enable_aggregation(AGGR_ONLY_DATA_CFM, DE_HI_MAX_SIZE); #elif (DE_AGGREGATE_HI_DATA == CFG_AGGR_LAST_MARK) wei_enable_aggregation(AGGR_LAST_MARK, DE_HI_MAX_SIZE); #endif WiFiEngine_EnableLinkSupervision(basic->linkSupervision.enable); WiFiEngine_SetLinkSupervisionBeaconFailCount(basic->linkSupervision.beaconFailCount); /* TODO: implement this before enabling this WiFiEngine_SetLinkSupervisionBeaconWarningCount(basic->linkSupervision.beaconWarningCount); */ WiFiEngine_LinksupervisionTimeout(4000,5); WiFiEngine_SetLinkSupervisionBeaconTimeout(basic->linkSupervision.beaconTimeout); WiFiEngine_SetLinkSupervisionTxFailureCount(basic->linkSupervision.TxFailureCount); WiFiEngine_SetLinkSupervisionRoundtripCount(basic->linkSupervision.roundtripCount); WiFiEngine_SetLinkSupervisionRoundtripSilent(basic->linkSupervision.roundtripSilent); WiFiEngine_SetPSTrafficTimeout(registry.powerManagement.psTrafficTimeout); WiFiEngine_SetPSWMMPeriod(basic->wmmPsPeriod); WiFiEngine_SetLvl1AdaptiveTxRate(basic->txRatePowerControl); if (basic->multiDomainCapabilityEnforced) { basic->multiDomainCapabilityEnabled = 1; } WiFiEngine_SetMultiDomainCapability(basic->multiDomainCapabilityEnabled); WiFiEngine_ConfigUDPBroadcastFilter(basic->DHCPBroadcastFilter); WiFiEngine_ReregisterAllVirtualTriggers(); WiFiEngine_ActivateRegionChannels(); wei_reconfigure_roam(); wei_reconfigure_mib(); wei_reconfigure_auth(); we_lqm_configure_lqm_job(); wei_multicast_update(); wei_arp_filter_configure(); WiFiEngine_EnableBTCoex((bool_t)basic->enableBTCoex); wei_get_mib_with_update(MIB_dot11manufacturerProductVersion, wifiEngineState.x_mac_version, sizeof(wifiEngineState.x_mac_version), NULL, WE_IND_NOOP); DE_MEMSET(&wifiEngineState.fw_capabilities, 0, sizeof(wifiEngineState.fw_capabilities)); wei_get_mib_with_update(MIB_dot11firmwareCapabilites, &wifiEngineState.fw_capabilities, sizeof wifiEngineState.fw_capabilities, NULL, WE_IND_NOOP); if(registry.network.basic.cmdTimeout) { WiFiEngine_CommandTimeoutStart(); } /* *************************************************************/ /* Init complete must be called before starting any scan jobs! */ /* *************************************************************/ WiFiEngine_Init_Complete(); wei_reconfigure_scan(); if(basic->defaultScanJobDisposition) { int status; /* Start default scan job */ status = WiFiEngine_SetScanJobState(0, 1, NULL); if(status != WIFI_ENGINE_SUCCESS) DE_TRACE_INT(TR_INITIALIZE, "WiFiEngine_SetScanJobState=%d\n", status); } wifiEngineState.periodic_scan_interval = basic->connectionPolicy.disconnectedScanInterval; #if (DE_BUILTIN_SUPPLICANT == CFG_INCLUDED) wpa_init(); #endif WES_SET_FLAG(WES_DEVICE_CONFIGURED); wei_sm_queue_sig(INTSIG_POWER_UP, SYSDEF_OBJID_HOST_MANAGER_TRAFFIC, DUMMY, FALSE); wei_sm_queue_sig(INTSIG_POWER_UP, SYSDEF_OBJID_HOST_MANAGER_PS, DUMMY, FALSE); #if (DE_NETWORK_SUPPORT & CFG_NETWORK_AMP) wei_sm_queue_sig(INTSIG_POWER_UP, SYSDEF_OBJID_HOST_MANAGER_PAL, DUMMY, FALSE); #endif wei_sm_execute(); #ifdef CONNECT_ON_PROP_SET if (basic->desiredSSID.hdr.id == M80211_IE_ID_SSID) { int status; DE_TRACE_STATIC(TR_INITIALIZE, "Desired SSID set in the registry"); status = WiFiEngine_sac_start(); if (status != WIFI_ENGINE_SUCCESS) DE_TRACE_INT(TR_INITIALIZE, "WiFiEngine_sac_start=%d\n", status); } #endif DE_TRACE_STATIC(TR_INITIALIZE, "Done!\n"); return WIFI_ENGINE_SUCCESS; }
static int hostapd_setup_interface(struct hostapd_data *hapd) { struct hostapd_config *conf = hapd->conf; u8 ssid[HOSTAPD_SSID_LEN + 1]; int ssid_len, set_ssid; int ret = 0; if (hostapd_driver_init(hapd)) { printf("%s driver initialization failed.\n", hapd->driver ? hapd->driver->name : "Unknown"); hapd->driver = NULL; return -1; } /* * Fetch the SSID from the system and use it or, * if one was specified in the config file, verify they * match. */ ssid_len = hostapd_get_ssid(hapd, ssid, sizeof(ssid)); if (ssid_len < 0) { printf("Could not read SSID from system\n"); return -1; } if (conf->ssid_set) { /* * If SSID is specified in the config file and it differs * from what is being used then force installation of the * new SSID. */ set_ssid = (conf->ssid_len != ssid_len || memcmp(conf->ssid, ssid, ssid_len) != 0); } else { /* * No SSID in the config file; just use the one we got * from the system. */ set_ssid = 0; conf->ssid_len = ssid_len; memcpy(conf->ssid, ssid, conf->ssid_len); conf->ssid[conf->ssid_len] = '\0'; } printf("Using interface %s with hwaddr " MACSTR " and ssid '%s'\n", hapd->conf->iface, MAC2STR(hapd->own_addr), hapd->conf->ssid); if (hostapd_setup_wpa_psk(conf)) { printf("WPA-PSK setup failed.\n"); return -1; } /* Set SSID for the kernel driver (to be used in beacon and probe * response frames) */ if (set_ssid && hostapd_set_ssid(hapd, (u8 *) conf->ssid, conf->ssid_len)) { printf("Could not set SSID for kernel driver\n"); return -1; } if (HOSTAPD_DEBUG_COND(HOSTAPD_DEBUG_MSGDUMPS)) conf->radius->msg_dumps = 1; hapd->radius = radius_client_init(hapd, conf->radius); if (hapd->radius == NULL) { printf("RADIUS client initialization failed.\n"); return -1; } if (conf->radius_server_clients) { struct radius_server_conf srv; memset(&srv, 0, sizeof(srv)); srv.client_file = conf->radius_server_clients; srv.auth_port = conf->radius_server_auth_port; srv.hostapd_conf = conf; srv.eap_sim_db_priv = hapd->eap_sim_db_priv; srv.ssl_ctx = hapd->ssl_ctx; srv.ipv6 = conf->radius_server_ipv6; hapd->radius_srv = radius_server_init(&srv); if (hapd->radius_srv == NULL) { printf("RADIUS server initialization failed.\n"); return -1; } } if (hostapd_acl_init(hapd)) { printf("ACL initialization failed.\n"); return -1; } if (ieee802_1x_init(hapd)) { printf("IEEE 802.1X initialization failed.\n"); return -1; } if (hapd->conf->wpa && wpa_init(hapd)) { printf("WPA initialization failed.\n"); return -1; } #ifdef SIMPLE_CONFIG if (wsc_ie_init(hapd) < 0) { printf("WSC IE initialization failed.\n"); return -1; } #endif if (accounting_init(hapd)) { printf("Accounting initialization failed.\n"); return -1; } if (hapd->conf->ieee802_11f && (hapd->iapp = iapp_init(hapd, hapd->conf->iapp_iface)) == NULL) { printf("IEEE 802.11F (IAPP) initialization failed.\n"); return -1; } if (hostapd_wireless_event_init(hapd) < 0) return -1; if (hostapd_flush_old_stations(hapd)) return -1; if (hostapd_ctrl_iface_init(hapd)) { printf("Failed to setup control interface\n"); ret = -1; } return ret; }