static void hostapd_free_hapd_data(struct hostapd_data *hapd) { iapp_deinit(hapd->iapp); hapd->iapp = NULL; accounting_deinit(hapd); hostapd_deinit_wpa(hapd); vlan_deinit(hapd); hostapd_acl_deinit(hapd); #ifndef CONFIG_NO_RADIUS radius_client_deinit(hapd->radius); hapd->radius = NULL; radius_das_deinit(hapd->radius_das); hapd->radius_das = NULL; #endif /* CONFIG_NO_RADIUS */ hostapd_deinit_wps(hapd); authsrv_deinit(hapd); if (hapd->interface_added && hostapd_if_remove(hapd, WPA_IF_AP_BSS, hapd->conf->iface)) { wpa_printf(MSG_WARNING, "Failed to remove BSS interface %s", hapd->conf->iface); } os_free(hapd->probereq_cb); hapd->probereq_cb = NULL; #ifdef CONFIG_P2P wpabuf_free(hapd->p2p_beacon_ie); hapd->p2p_beacon_ie = NULL; wpabuf_free(hapd->p2p_probe_resp_ie); hapd->p2p_probe_resp_ie = NULL; #endif /* CONFIG_P2P */ wpabuf_free(hapd->time_adv); #ifdef CONFIG_INTERWORKING gas_serv_deinit(hapd); #endif /* CONFIG_INTERWORKING */ #ifdef CONFIG_SQLITE os_free(hapd->tmp_eap_user.identity); os_free(hapd->tmp_eap_user.password); #endif /* CONFIG_SQLITE */ }
static void hostapd_cleanup(hostapd *hapd) { free(hapd->default_wep_key); if (hapd->conf->ieee802_11f) iapp_deinit(hapd); accounting_deinit(hapd); wpa_deinit(hapd); ieee802_1x_deinit(hapd); hostapd_acl_deinit(hapd); radius_client_deinit(hapd); hostapd_wireless_event_deinit(hapd->driver.data); hostapd_driver_deinit(hapd); hostapd_config_free(hapd->conf); hapd->conf = NULL; free(hapd->config_fname); }
static void hostapd_cleanup(struct hostapd_data *hapd) { hostapd_ctrl_iface_deinit(hapd); free(hapd->default_wep_key); hapd->default_wep_key = NULL; iapp_deinit(hapd->iapp); accounting_deinit(hapd); wpa_deinit(hapd); #ifdef SIMPLE_CONFIG wsc_ie_deinit(hapd); #endif ieee802_1x_deinit(hapd); hostapd_acl_deinit(hapd); radius_client_deinit(hapd->radius); hapd->radius = NULL; radius_server_deinit(hapd->radius_srv); hapd->radius_srv = NULL; hostapd_wireless_event_deinit(hapd); if (hapd->driver) hostapd_driver_deinit(hapd); hostapd_config_free(hapd->conf); hapd->conf = NULL; free(hapd->config_fname); #ifdef EAP_TLS_FUNCS if (hapd->ssl_ctx) { tls_deinit(hapd->ssl_ctx); hapd->ssl_ctx = NULL; } #endif /* EAP_TLS_FUNCS */ if (hapd->eap_sim_db_priv) eap_sim_db_deinit(hapd->eap_sim_db_priv); }
/** * hostapd_cleanup - Per-BSS cleanup (deinitialization) * @hapd: Pointer to BSS data * * This function is used to free all per-BSS data structures and resources. * This gets called in a loop for each BSS between calls to * hostapd_cleanup_iface_pre() and hostapd_cleanup_iface() when an interface * is deinitialized. Most of the modules that are initialized in * hostapd_setup_bss() are deinitialized here. */ static void hostapd_cleanup(struct hostapd_data *hapd) { if (hapd->iface->ctrl_iface_deinit) hapd->iface->ctrl_iface_deinit(hapd); iapp_deinit(hapd->iapp); hapd->iapp = NULL; accounting_deinit(hapd); hostapd_deinit_wpa(hapd); vlan_deinit(hapd); hostapd_acl_deinit(hapd); #ifndef CONFIG_NO_RADIUS radius_client_deinit(hapd->radius); hapd->radius = NULL; #endif /* CONFIG_NO_RADIUS */ hostapd_deinit_wps(hapd); authsrv_deinit(hapd); if (hapd->interface_added && hostapd_if_remove(hapd, WPA_IF_AP_BSS, hapd->conf->iface)) { wpa_printf(MSG_WARNING, "Failed to remove BSS interface %s", hapd->conf->iface); } os_free(hapd->probereq_cb); hapd->probereq_cb = NULL; #ifdef CONFIG_P2P wpabuf_free(hapd->p2p_beacon_ie); hapd->p2p_beacon_ie = NULL; wpabuf_free(hapd->p2p_probe_resp_ie); hapd->p2p_probe_resp_ie = NULL; #endif /* CONFIG_P2P */ wpabuf_free(hapd->time_adv); }
struct iapp_data * iapp_init(struct hostapd_data *hapd, const char *iface) { struct ifreq ifr; struct sockaddr_ll addr; int ifindex; struct sockaddr_in *paddr, uaddr; struct iapp_data *iapp; struct ip_mreqn mreq; iapp = os_zalloc(sizeof(*iapp)); if (iapp == NULL) return NULL; iapp->hapd = hapd; iapp->udp_sock = iapp->packet_sock = -1; /* TODO: * open socket for sending and receiving IAPP frames over TCP */ iapp->udp_sock = socket(PF_INET, SOCK_DGRAM, 0); if (iapp->udp_sock < 0) { perror("socket[PF_INET,SOCK_DGRAM]"); iapp_deinit(iapp); return NULL; } os_memset(&ifr, 0, sizeof(ifr)); os_strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)); if (ioctl(iapp->udp_sock, SIOCGIFINDEX, &ifr) != 0) { perror("ioctl(SIOCGIFINDEX)"); iapp_deinit(iapp); return NULL; } ifindex = ifr.ifr_ifindex; if (ioctl(iapp->udp_sock, SIOCGIFADDR, &ifr) != 0) { perror("ioctl(SIOCGIFADDR)"); iapp_deinit(iapp); return NULL; } paddr = (struct sockaddr_in *) &ifr.ifr_addr; if (paddr->sin_family != AF_INET) { printf("Invalid address family %i (SIOCGIFADDR)\n", paddr->sin_family); iapp_deinit(iapp); return NULL; } iapp->own.s_addr = paddr->sin_addr.s_addr; if (ioctl(iapp->udp_sock, SIOCGIFBRDADDR, &ifr) != 0) { perror("ioctl(SIOCGIFBRDADDR)"); iapp_deinit(iapp); return NULL; } paddr = (struct sockaddr_in *) &ifr.ifr_addr; if (paddr->sin_family != AF_INET) { printf("Invalid address family %i (SIOCGIFBRDADDR)\n", paddr->sin_family); iapp_deinit(iapp); return NULL; } inet_aton(IAPP_MULTICAST, &iapp->multicast); os_memset(&uaddr, 0, sizeof(uaddr)); uaddr.sin_family = AF_INET; uaddr.sin_port = htons(IAPP_UDP_PORT); if (bind(iapp->udp_sock, (struct sockaddr *) &uaddr, sizeof(uaddr)) < 0) { perror("bind[UDP]"); iapp_deinit(iapp); return NULL; } os_memset(&mreq, 0, sizeof(mreq)); mreq.imr_multiaddr = iapp->multicast; mreq.imr_address.s_addr = INADDR_ANY; mreq.imr_ifindex = 0; if (setsockopt(iapp->udp_sock, SOL_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) { perror("setsockopt[UDP,IP_ADD_MEMBERSHIP]"); iapp_deinit(iapp); return NULL; } iapp->packet_sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (iapp->packet_sock < 0) { perror("socket[PF_PACKET,SOCK_RAW]"); iapp_deinit(iapp); return NULL; } os_memset(&addr, 0, sizeof(addr)); addr.sll_family = AF_PACKET; addr.sll_ifindex = ifindex; if (bind(iapp->packet_sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { perror("bind[PACKET]"); iapp_deinit(iapp); return NULL; } if (eloop_register_read_sock(iapp->udp_sock, iapp_receive_udp, iapp, NULL)) { printf("Could not register read socket for IAPP.\n"); iapp_deinit(iapp); return NULL; } printf("IEEE 802.11F (IAPP) using interface %s\n", iface); /* TODO: For levels 2 and 3: send RADIUS Initiate-Request, receive * RADIUS Initiate-Accept or Initiate-Reject. IAPP port should actually * be openned only after receiving Initiate-Accept. If Initiate-Reject * is received, IAPP is not started. */ return iapp; }