aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Paulo <rpaulo@FreeBSD.org>2010-10-29 08:01:21 +0000
committerRui Paulo <rpaulo@FreeBSD.org>2010-10-29 08:01:21 +0000
commit02b5aa59ffe0c7ce093caa72e935418a1b0ae370 (patch)
tree0b2308ac0b6239b9bd8d56cb4a658ca35f20a06b
parent95ea342968b919b418b028d9360eedf685a55220 (diff)
downloadsrc-02b5aa59ffe0c7ce093caa72e935418a1b0ae370.tar.gz
src-02b5aa59ffe0c7ce093caa72e935418a1b0ae370.zip
Import wpa_supplicant / hostapd 0.7.3.
Changes: 2010-09-07 - v0.7.3 * fixed fallback from failed PMKSA caching into full EAP authentication [Bug 355] * fixed issue with early D-Bus signals during initialization * fixed X.509 name handling in internal TLS * fixed WPS ER to use corrent Enrollee MAC Address in Credential * fixed scanning routines ot improve AP selection for WPS * added WPS workaround for open networks * fixed WPS Diffie-Hellman derivation to use correct public key length * fixed wpa_supplicant AP mode operations to ignore Supplicant and scan result events * improved SME operations with nl80211 * fixed WPS ER event_id handling in some cases * fixed some issues with bgscan simple to avoid unnecessary scans * fixed issue with l2_packet_ndis overlapped writes corrupting stack [Bug 328] * updated WinPcap to the latest stable version 4.1.2 in Windows installer 2010-04-18 - v0.7.2 * nl80211: fixed number of issues with roaming * avoid unnecessary roaming if multiple APs with similar signal strength are present in scan results * add TLS client events and server probing to ease design of automatic detection of EAP parameters * add option for server certificate matching (SHA256 hash of the certificate) instead of trusted CA certificate configuration * bsd: Cleaned up driver wrapper and added various low-level configuration options * wpa_gui-qt4: do not show too frequent WPS AP available events as tray messages * TNC: fixed issues with fragmentation * EAP-TNC: add Flags field into fragment acknowledgement (needed to interoperate with other implementations; may potentially breaks compatibility with older wpa_supplicant/hostapd versions) * wpa_cli: added option for using a separate process to receive event messages to reduce latency in showing these (CFLAGS += -DCONFIG_WPA_CLI_FORK=y in .config to enable this) * maximum BSS table size can now be configured (bss_max_count) * BSSes to be included in the BSS table can be filtered based on configured SSIDs to save memory (filter_ssids) * fix number of issues with IEEE 802.11r/FT; this version is not backwards compatible with old versions * nl80211: add support for IEEE 802.11r/FT protocol (both over-the-air and over-the-DS) * add freq_list network configuration parameter to allow the AP selection to filter out entries based on the operating channel * add signal strength change events for bgscan; this allows more dynamic changes to background scanning interval based on changes in the signal strength with the current AP; this improves roaming within ESS quite a bit, e.g., with bgscan="simple:30:-45:300" in the network configuration block to request background scans less frequently when signal strength remains good and to automatically trigger background scans whenever signal strength drops noticeably (this is currently only available with nl80211) * add BSSID and reason code (if available) to disconnect event messages * wpa_gui-qt4: more complete support for translating the GUI with linguist and add German translation * fix DH padding with internal crypto code (mainly, for WPS) * do not trigger initial scan automatically anymore if there are no enabled networks 2010-01-16 - v0.7.1 * cleaned up driver wrapper API (struct wpa_driver_ops); the new API is not fully backwards compatible, so out-of-tree driver wrappers will need modifications * cleaned up various module interfaces * merge hostapd and wpa_supplicant developers' documentation into a single document * nl80211: use explicit deauthentication to clear cfg80211 state to avoid issues when roaming between APs * dbus: major design changes in the new D-Bus API (fi.w1.wpa_supplicant1) * nl80211: added support for IBSS networks * added internal debugging mechanism with backtrace support and memory allocation/freeing validation, etc. tests (CONFIG_WPA_TRACE=y) * added WPS ER unsubscription command to more cleanly unregister from receiving UPnP events when ER is terminated * cleaned up AP mode operations to avoid need for virtual driver_ops wrapper * added BSS table to maintain more complete scan result information over multiple scans (that may include only partial results) * wpa_gui-qt4: update Peers dialog information more dynamically while the dialog is kept open * fixed PKCS#12 use with OpenSSL 1.0.0 * driver_wext: Added cfg80211-specific optimization to avoid some unnecessary scans and to speed up association 2009-11-21 - v0.7.0 * increased wpa_cli ping interval to 5 seconds and made this configurable with a new command line options (-G<seconds>) * fixed scan buffer processing with WEXT to handle up to 65535 byte result buffer (previously, limited to 32768 bytes) * allow multiple driver wrappers to be specified on command line (e.g., -Dnl80211,wext); the first one that is able to initialize the interface will be used * added support for multiple SSIDs per scan request to optimize scan_ssid=1 operations in ap_scan=1 mode (i.e., search for hidden SSIDs); this requires driver support and can currently be used only with nl80211 * added support for WPS USBA out-of-band mechanism with USB Flash Drives (UFD) (CONFIG_WPS_UFD=y) * driver_ndis: add PAE group address to the multicast address list to fix wired IEEE 802.1X authentication * fixed IEEE 802.11r key derivation function to match with the standard (note: this breaks interoperability with previous version) [Bug 303] * added better support for drivers that allow separate authentication and association commands (e.g., mac80211-based Linux drivers with nl80211; SME in wpa_supplicant); this allows over-the-air FT protocol to be used (IEEE 802.11r) * fixed SHA-256 based key derivation function to match with the standard when using CCMP (for IEEE 802.11r and IEEE 802.11w) (note: this breaks interoperability with previous version) [Bug 307] * use shared driver wrapper files with hostapd * added AP mode functionality (CONFIG_AP=y) with mode=2 in the network block; this can be used for open and WPA2-Personal networks (optionally, with WPS); this links in parts of hostapd functionality into wpa_supplicant * wpa_gui-qt4: added new Peers dialog to show information about peers (other devices, including APs and stations, etc. in the neighborhood) * added support for WPS External Registrar functionality (configure APs and enroll new devices); can be used with wpa_gui-qt4 Peers dialog and wpa_cli commands wps_er_start, wps_er_stop, wps_er_pin, wps_er_pbc, wps_er_learn (this can also be used with a new 'none' driver wrapper if no wireless device or IEEE 802.1X on wired is needed) * driver_nl80211: multiple updates to provide support for new Linux nl80211/mac80211 functionality * updated management frame protection to use IEEE Std 802.11w-2009 * fixed number of small WPS issues and added workarounds to interoperate with common deployed broken implementations * added support for NFC out-of-band mechanism with WPS * driver_ndis: fixed wired IEEE 802.1X authentication with PAE group address frames * added preliminary support for IEEE 802.11r RIC processing * added support for specifying subset of enabled frequencies to scan (scan_freq option in the network configuration block); this can speed up scanning process considerably if it is known that only a small subset of channels is actually used in the network (this is currently supported only with -Dnl80211) * added a workaround for race condition between receiving the association event and the following EAPOL-Key * added background scan and roaming infrastructure to allow network-specific optimizations to be used to improve roaming within an ESS (same SSID) * added new DBus interface (fi.w1.wpa_supplicant1)
Notes
Notes: svn path=/vendor/wpa/dist/; revision=214501
-rw-r--r--hostapd/ChangeLog597
-rw-r--r--hostapd/Makefile635
-rw-r--r--hostapd/README390
-rw-r--r--hostapd/README-WPS239
-rw-r--r--hostapd/config.c2622
-rw-r--r--hostapd/ctrl_iface.c610
-rw-r--r--hostapd/defconfig144
-rw-r--r--hostapd/doc/code_structure.doxygen5
-rw-r--r--hostapd/doc/ctrl_iface.doxygen66
-rw-r--r--hostapd/doc/doxygen.fast238
-rw-r--r--hostapd/doc/doxygen.full238
-rw-r--r--hostapd/doc/driver_wrapper.doxygen20
-rw-r--r--hostapd/doc/eap.doxygen56
-rw-r--r--hostapd/doc/hostapd.fig264
-rwxr-xr-xhostapd/doc/kerneldoc2doxygen.pl129
-rw-r--r--hostapd/doc/mainpage.doxygen52
-rw-r--r--hostapd/doc/porting.doxygen5
-rw-r--r--hostapd/driver.h798
-rw-r--r--hostapd/driver_bsd.c839
-rw-r--r--hostapd/driver_hostap.c1279
-rw-r--r--hostapd/driver_madwifi.c1483
-rw-r--r--hostapd/driver_nl80211.c2708
-rw-r--r--hostapd/driver_prism54.c1091
-rw-r--r--hostapd/driver_test.c1300
-rw-r--r--hostapd/driver_wired.c372
-rw-r--r--hostapd/drivers.c77
-rw-r--r--hostapd/eap_testing.txt77
-rw-r--r--hostapd/hostap_common.h216
-rw-r--r--hostapd/hostapd.859
-rw-r--r--hostapd/hostapd.accept6
-rw-r--r--hostapd/hostapd.c2039
-rw-r--r--hostapd/hostapd.conf1025
-rw-r--r--hostapd/hostapd.deny5
-rw-r--r--hostapd/hostapd.eap_user91
-rw-r--r--hostapd/hostapd.h238
-rw-r--r--hostapd/hostapd.radius_clients4
-rw-r--r--hostapd/hostapd.sim_db9
-rw-r--r--hostapd/hostapd.vlan9
-rw-r--r--hostapd/hostapd.wpa_psk9
-rw-r--r--hostapd/hostapd_cli.183
-rw-r--r--hostapd/hostapd_cli.c677
-rw-r--r--hostapd/logwatch/README9
-rwxr-xr-xhostapd/logwatch/hostapd65
-rw-r--r--hostapd/logwatch/hostapd.conf10
-rw-r--r--hostapd/nt_password_hash.c52
-rw-r--r--hostapd/prism54.h177
-rw-r--r--hostapd/priv_netlink.h71
-rw-r--r--hostapd/radiotap.h242
-rw-r--r--hostapd/sta_info.h43
-rw-r--r--hostapd/wired.conf40
-rw-r--r--hostapd/wme.h112
-rw-r--r--patches/openssl-0.9.8-tls-extensions.patch429
-rw-r--r--patches/openssl-0.9.8d-tls-extensions.patch429
-rw-r--r--patches/openssl-0.9.8e-tls-extensions.patch353
-rw-r--r--patches/openssl-0.9.8g-tls-extensions.patch330
-rw-r--r--patches/openssl-0.9.8h-tls-extensions.patch344
-rw-r--r--patches/openssl-0.9.8i-tls-extensions.patch404
-rw-r--r--patches/openssl-0.9.9-session-ticket.patch374
-rw-r--r--src/Makefile4
-rw-r--r--src/ap/Makefile (renamed from src/hlr_auc_gw/Makefile)1
-rw-r--r--src/ap/accounting.c (renamed from hostapd/accounting.c)35
-rw-r--r--src/ap/accounting.h (renamed from hostapd/accounting.h)25
-rw-r--r--src/ap/ap_config.c605
-rw-r--r--src/ap/ap_config.h (renamed from hostapd/config.h)55
-rw-r--r--src/ap/ap_drv_ops.c621
-rw-r--r--src/ap/ap_drv_ops.h67
-rw-r--r--src/ap/ap_list.c (renamed from hostapd/ap_list.c)136
-rw-r--r--src/ap/ap_list.h (renamed from hostapd/ap_list.h)19
-rw-r--r--src/ap/ap_mlme.c (renamed from hostapd/mlme.c)12
-rw-r--r--src/ap/ap_mlme.h (renamed from hostapd/mlme.h)0
-rw-r--r--src/ap/authsrv.c216
-rw-r--r--src/ap/authsrv.h (renamed from src/crypto/rc4.h)14
-rw-r--r--src/ap/beacon.c (renamed from hostapd/beacon.c)131
-rw-r--r--src/ap/beacon.h (renamed from hostapd/beacon.h)16
-rw-r--r--src/ap/ctrl_iface_ap.c104
-rw-r--r--src/ap/ctrl_iface_ap.h25
-rw-r--r--src/ap/drv_callbacks.c457
-rw-r--r--src/ap/hostapd.c887
-rw-r--r--src/ap/hostapd.h276
-rw-r--r--src/ap/hw_features.c (renamed from hostapd/hw_features.c)309
-rw-r--r--src/ap/hw_features.h (renamed from hostapd/hw_features.h)70
-rw-r--r--src/ap/iapp.c (renamed from hostapd/iapp.c)32
-rw-r--r--src/ap/iapp.h (renamed from hostapd/iapp.h)9
-rw-r--r--src/ap/ieee802_11.c (renamed from hostapd/ieee802_11.c)1126
-rw-r--r--src/ap/ieee802_11.h (renamed from hostapd/ieee802_11.h)53
-rw-r--r--src/ap/ieee802_11_auth.c (renamed from hostapd/ieee802_11_auth.c)65
-rw-r--r--src/ap/ieee802_11_auth.h (renamed from hostapd/ieee802_11_auth.h)2
-rw-r--r--src/ap/ieee802_11_ht.c270
-rw-r--r--src/ap/ieee802_1x.c (renamed from hostapd/ieee802_1x.c)423
-rw-r--r--src/ap/ieee802_1x.h (renamed from hostapd/ieee802_1x.h)21
-rw-r--r--src/ap/peerkey_auth.c (renamed from hostapd/peerkey.c)15
-rw-r--r--src/ap/pmksa_cache_auth.c (renamed from hostapd/pmksa_cache.c)110
-rw-r--r--src/ap/pmksa_cache_auth.h (renamed from hostapd/pmksa_cache.h)22
-rw-r--r--src/ap/preauth_auth.c (renamed from hostapd/preauth.c)19
-rw-r--r--src/ap/preauth_auth.h (renamed from hostapd/preauth.h)0
-rw-r--r--src/ap/sta_info.c (renamed from hostapd/sta_info.c)120
-rw-r--r--src/ap/sta_info.h (renamed from hostapd/ap.h)60
-rw-r--r--src/ap/tkip_countermeasures.c93
-rw-r--r--src/ap/tkip_countermeasures.h (renamed from hostapd/ctrl_iface.h)13
-rw-r--r--src/ap/utils.c88
-rw-r--r--src/ap/vlan_init.c (renamed from hostapd/vlan_init.c)231
-rw-r--r--src/ap/vlan_init.h (renamed from hostapd/vlan_init.h)32
-rw-r--r--src/ap/wmm.c (renamed from hostapd/wme.c)101
-rw-r--r--src/ap/wmm.h29
-rw-r--r--src/ap/wpa_auth.c (renamed from hostapd/wpa.c)311
-rw-r--r--src/ap/wpa_auth.h (renamed from hostapd/wpa.h)39
-rw-r--r--src/ap/wpa_auth_ft.c (renamed from hostapd/wpa_ft.c)474
-rw-r--r--src/ap/wpa_auth_glue.c545
-rw-r--r--src/ap/wpa_auth_glue.h22
-rw-r--r--src/ap/wpa_auth_i.h (renamed from hostapd/wpa_auth_i.h)9
-rw-r--r--src/ap/wpa_auth_ie.c (renamed from hostapd/wpa_auth_ie.c)30
-rw-r--r--src/ap/wpa_auth_ie.h (renamed from hostapd/wpa_auth_ie.h)2
-rw-r--r--src/ap/wps_hostapd.c (renamed from hostapd/wps_hostapd.c)599
-rw-r--r--src/ap/wps_hostapd.h (renamed from hostapd/wps_hostapd.h)31
-rw-r--r--src/common/Makefile1
-rw-r--r--src/common/defs.h80
-rw-r--r--src/common/ieee802_11_common.c75
-rw-r--r--src/common/ieee802_11_common.h54
-rw-r--r--src/common/ieee802_11_defs.h270
-rw-r--r--src/common/privsep_commands.h3
-rw-r--r--src/common/version.h2
-rw-r--r--src/common/wpa_common.c233
-rw-r--r--src/common/wpa_common.h16
-rw-r--r--src/common/wpa_ctrl.h23
-rw-r--r--src/crypto/.gitignore1
-rw-r--r--src/crypto/Makefile55
-rw-r--r--src/crypto/aes-cbc.c86
-rw-r--r--src/crypto/aes-ctr.c61
-rw-r--r--src/crypto/aes-eax.c151
-rw-r--r--src/crypto/aes-encblock.c38
-rw-r--r--src/crypto/aes-internal-dec.c151
-rw-r--r--src/crypto/aes-internal-enc.c121
-rw-r--r--src/crypto/aes-internal.c (renamed from src/crypto/aes.c)350
-rw-r--r--src/crypto/aes-omac1.c124
-rw-r--r--src/crypto/aes-unwrap.c79
-rw-r--r--src/crypto/aes-wrap.c76
-rw-r--r--src/crypto/aes.h2
-rw-r--r--src/crypto/aes_i.h122
-rw-r--r--src/crypto/aes_wrap.c533
-rw-r--r--src/crypto/crypto.h54
-rw-r--r--src/crypto/crypto_cryptoapi.c29
-rw-r--r--src/crypto/crypto_gnutls.c24
-rw-r--r--src/crypto/crypto_internal-cipher.c256
-rw-r--r--src/crypto/crypto_internal-modexp.c55
-rw-r--r--src/crypto/crypto_internal-rsa.c115
-rw-r--r--src/crypto/crypto_internal.c639
-rw-r--r--src/crypto/crypto_libtomcrypt.c24
-rw-r--r--src/crypto/crypto_none.c3
-rw-r--r--src/crypto/crypto_nss.c213
-rw-r--r--src/crypto/crypto_openssl.c313
-rw-r--r--src/crypto/des-internal.c (renamed from src/crypto/des.c)40
-rw-r--r--src/crypto/des_i.h31
-rw-r--r--src/crypto/dh_group5.c40
-rw-r--r--src/crypto/dh_group5.h23
-rw-r--r--src/crypto/dh_groups.c3
-rw-r--r--src/crypto/fips_prf_cryptoapi.c25
-rw-r--r--src/crypto/fips_prf_gnutls.c26
-rw-r--r--src/crypto/fips_prf_internal.c74
-rw-r--r--src/crypto/fips_prf_nss.c25
-rw-r--r--src/crypto/fips_prf_openssl.c83
-rw-r--r--src/crypto/md4-internal.c (renamed from src/crypto/md4.c)8
-rw-r--r--src/crypto/md5-internal.c293
-rw-r--r--src/crypto/md5-non-fips.c113
-rw-r--r--src/crypto/md5.c307
-rw-r--r--src/crypto/md5.h29
-rw-r--r--src/crypto/md5_i.h29
-rw-r--r--src/crypto/milenage.c329
-rw-r--r--src/crypto/milenage.h (renamed from src/hlr_auc_gw/milenage.h)4
-rw-r--r--src/crypto/ms_funcs.c130
-rw-r--r--src/crypto/ms_funcs.h54
-rw-r--r--src/crypto/rc4.c20
-rw-r--r--src/crypto/sha1-internal.c308
-rw-r--r--src/crypto/sha1-pbkdf2.c100
-rw-r--r--src/crypto/sha1-tlsprf.c109
-rw-r--r--src/crypto/sha1-tprf.c76
-rw-r--r--src/crypto/sha1.c612
-rw-r--r--src/crypto/sha1.h29
-rw-r--r--src/crypto/sha1_i.h29
-rw-r--r--src/crypto/sha256-internal.c243
-rw-r--r--src/crypto/sha256.c225
-rw-r--r--src/crypto/tls.h127
-rw-r--r--src/crypto/tls_gnutls.c235
-rw-r--r--src/crypto/tls_internal.c170
-rw-r--r--src/crypto/tls_none.c49
-rw-r--r--src/crypto/tls_nss.c680
-rw-r--r--src/crypto/tls_openssl.c548
-rw-r--r--src/crypto/tls_schannel.c162
-rw-r--r--src/drivers/.gitignore2
-rw-r--r--src/drivers/Makefile2
-rw-r--r--src/drivers/driver.h1718
-rw-r--r--src/drivers/driver_atheros.c (renamed from hostapd/driver_atheros.c)667
-rw-r--r--src/drivers/driver_atmel.c31
-rw-r--r--src/drivers/driver_broadcom.c119
-rw-r--r--src/drivers/driver_bsd.c1460
-rw-r--r--src/drivers/driver_hostap.c1168
-rw-r--r--src/drivers/driver_hostap.h71
-rw-r--r--src/drivers/driver_iphone.m2
-rw-r--r--src/drivers/driver_ipw.c35
-rw-r--r--src/drivers/driver_madwifi.c1305
-rw-r--r--src/drivers/driver_ndis.c181
-rw-r--r--src/drivers/driver_ndis.h1
-rw-r--r--src/drivers/driver_ndiswrapper.c42
-rw-r--r--src/drivers/driver_nl80211.c6004
-rw-r--r--src/drivers/driver_none.c (renamed from hostapd/driver_none.c)47
-rw-r--r--src/drivers/driver_osx.m89
-rw-r--r--src/drivers/driver_prism54.c381
-rw-r--r--src/drivers/driver_privsep.c118
-rw-r--r--src/drivers/driver_ps3.c186
-rw-r--r--src/drivers/driver_ralink.c654
-rw-r--r--src/drivers/driver_ralink.h3
-rw-r--r--src/drivers/driver_roboswitch.c20
-rw-r--r--src/drivers/driver_test.c2091
-rw-r--r--src/drivers/driver_wext.c552
-rw-r--r--src/drivers/driver_wext.h10
-rw-r--r--src/drivers/driver_wired.c420
-rw-r--r--src/drivers/drivers.c28
-rw-r--r--src/drivers/drivers.mak181
-rw-r--r--src/drivers/linux_ioctl.c198
-rw-r--r--src/drivers/linux_ioctl.h27
-rw-r--r--src/drivers/netlink.c204
-rw-r--r--src/drivers/netlink.h33
-rw-r--r--src/drivers/nl80211_copy.h (renamed from src/common/nl80211_copy.h)214
-rw-r--r--src/drivers/priv_netlink.h9
-rw-r--r--src/drivers/radiotap.c287
-rw-r--r--src/drivers/radiotap_iter.h41
-rw-r--r--src/drivers/scan_helpers.c182
-rw-r--r--src/drivers/wireless_copy.h (renamed from src/common/wireless_copy.h)0
-rw-r--r--src/eap_common/Makefile1
-rw-r--r--src/eap_common/chap.c9
-rw-r--r--src/eap_common/chap.h6
-rw-r--r--src/eap_common/eap_fast_common.c4
-rw-r--r--src/eap_common/eap_gpsk_common.c7
-rw-r--r--src/eap_common/eap_pax_common.c2
-rw-r--r--src/eap_common/eap_peap_common.c2
-rw-r--r--src/eap_common/eap_psk_common.c2
-rw-r--r--src/eap_common/eap_sake_common.c2
-rw-r--r--src/eap_common/eap_sim_common.c22
-rw-r--r--src/eap_common/eap_sim_common.h6
-rw-r--r--src/eap_common/ikev2_common.c6
-rw-r--r--src/eap_peer/Makefile1
-rw-r--r--src/eap_peer/eap.c77
-rw-r--r--src/eap_peer/eap.h2
-rw-r--r--src/eap_peer/eap_aka.c14
-rw-r--r--src/eap_peer/eap_config.h9
-rw-r--r--src/eap_peer/eap_fast.c12
-rw-r--r--src/eap_peer/eap_fast_pac.c29
-rw-r--r--src/eap_peer/eap_leap.c32
-rw-r--r--src/eap_peer/eap_md5.c2
-rw-r--r--src/eap_peer/eap_methods.c155
-rw-r--r--src/eap_peer/eap_methods.h23
-rw-r--r--src/eap_peer/eap_mschapv2.c19
-rw-r--r--src/eap_peer/eap_pax.c4
-rw-r--r--src/eap_peer/eap_peap.c12
-rw-r--r--src/eap_peer/eap_psk.c4
-rw-r--r--src/eap_peer/eap_sim.c6
-rw-r--r--src/eap_peer/eap_tls.c2
-rw-r--r--src/eap_peer/eap_tls_common.c164
-rw-r--r--src/eap_peer/eap_tls_common.h23
-rw-r--r--src/eap_peer/eap_tnc.c5
-rw-r--r--src/eap_peer/eap_ttls.c63
-rw-r--r--src/eap_peer/eap_wsc.c94
-rw-r--r--src/eap_peer/ikev2.c2
-rw-r--r--src/eap_peer/mschapv2.c26
-rw-r--r--src/eap_peer/mschapv2.h14
-rw-r--r--src/eap_server/Makefile1
-rw-r--r--src/eap_server/eap.h4
-rw-r--r--src/eap_server/eap_i.h2
-rw-r--r--src/eap_server/eap_methods.h36
-rw-r--r--src/eap_server/eap_server.c (renamed from src/eap_server/eap.c)19
-rw-r--r--src/eap_server/eap_server_aka.c (renamed from src/eap_server/eap_aka.c)35
-rw-r--r--src/eap_server/eap_server_fast.c (renamed from src/eap_server/eap_fast.c)106
-rw-r--r--src/eap_server/eap_server_gpsk.c (renamed from src/eap_server/eap_gpsk.c)0
-rw-r--r--src/eap_server/eap_server_gtc.c (renamed from src/eap_server/eap_gtc.c)8
-rw-r--r--src/eap_server/eap_server_identity.c (renamed from src/eap_server/eap_identity.c)0
-rw-r--r--src/eap_server/eap_server_ikev2.c (renamed from src/eap_server/eap_ikev2.c)0
-rw-r--r--src/eap_server/eap_server_md5.c (renamed from src/eap_server/eap_md5.c)0
-rw-r--r--src/eap_server/eap_server_methods.c (renamed from src/eap_server/eap_methods.c)177
-rw-r--r--src/eap_server/eap_server_mschapv2.c (renamed from src/eap_server/eap_mschapv2.c)28
-rw-r--r--src/eap_server/eap_server_pax.c (renamed from src/eap_server/eap_pax.c)0
-rw-r--r--src/eap_server/eap_server_peap.c (renamed from src/eap_server/eap_peap.c)149
-rw-r--r--src/eap_server/eap_server_psk.c (renamed from src/eap_server/eap_psk.c)4
-rw-r--r--src/eap_server/eap_server_sake.c (renamed from src/eap_server/eap_sake.c)0
-rw-r--r--src/eap_server/eap_server_sim.c (renamed from src/eap_server/eap_sim.c)0
-rw-r--r--src/eap_server/eap_server_tls.c (renamed from src/eap_server/eap_tls.c)4
-rw-r--r--src/eap_server/eap_server_tls_common.c (renamed from src/eap_server/eap_tls_common.c)125
-rw-r--r--src/eap_server/eap_server_tnc.c (renamed from src/eap_server/eap_tnc.c)99
-rw-r--r--src/eap_server/eap_server_ttls.c (renamed from src/eap_server/eap_ttls.c)133
-rw-r--r--src/eap_server/eap_server_vendor_test.c (renamed from src/eap_server/eap_vendor_test.c)0
-rw-r--r--src/eap_server/eap_server_wsc.c (renamed from src/eap_server/eap_wsc.c)41
-rw-r--r--src/eap_server/eap_sim_db.c4
-rw-r--r--src/eap_server/eap_sim_db.h16
-rw-r--r--src/eap_server/eap_tls_common.h39
-rw-r--r--src/eap_server/ikev2.c2
-rw-r--r--src/eap_server/tncs.c1
-rw-r--r--src/eapol_auth/Makefile8
-rw-r--r--src/eapol_auth/eapol_auth_dump.c231
-rw-r--r--src/eapol_auth/eapol_auth_sm.c (renamed from hostapd/eapol_sm.c)315
-rw-r--r--src/eapol_auth/eapol_auth_sm.h89
-rw-r--r--src/eapol_auth/eapol_auth_sm_i.h (renamed from hostapd/eapol_sm.h)99
-rw-r--r--src/eapol_supp/Makefile1
-rw-r--r--src/eapol_supp/eapol_supp_sm.c38
-rw-r--r--src/eapol_supp/eapol_supp_sm.h11
-rw-r--r--src/hlr_auc_gw/hlr_auc_gw.c714
-rw-r--r--src/hlr_auc_gw/hlr_auc_gw.milenage_db13
-rw-r--r--src/hlr_auc_gw/milenage.c1142
-rw-r--r--src/l2_packet/Makefile1
-rw-r--r--src/l2_packet/l2_packet_freebsd.c2
-rw-r--r--src/l2_packet/l2_packet_ndis.c16
-rw-r--r--src/l2_packet/l2_packet_privsep.c2
-rw-r--r--src/lib.rules21
-rw-r--r--src/radius/.gitignore1
-rw-r--r--src/radius/Makefile21
-rw-r--r--src/radius/radius.c293
-rw-r--r--src/radius/radius.h47
-rw-r--r--src/radius/radius_client.c354
-rw-r--r--src/radius/radius_client.h227
-rw-r--r--src/radius/radius_server.c299
-rw-r--r--src/radius/radius_server.h186
-rw-r--r--src/rsn_supp/Makefile1
-rw-r--r--src/rsn_supp/peerkey.c18
-rw-r--r--src/rsn_supp/pmksa_cache.c47
-rw-r--r--src/rsn_supp/pmksa_cache.h5
-rw-r--r--src/rsn_supp/preauth.c175
-rw-r--r--src/rsn_supp/preauth.h17
-rw-r--r--src/rsn_supp/wpa.c362
-rw-r--r--src/rsn_supp/wpa.h61
-rw-r--r--src/rsn_supp/wpa_ft.c344
-rw-r--r--src/rsn_supp/wpa_i.h28
-rw-r--r--src/rsn_supp/wpa_ie.c49
-rw-r--r--src/rsn_supp/wpa_ie.h4
-rw-r--r--src/tls/.gitignore1
-rw-r--r--src/tls/Makefile36
-rw-r--r--src/tls/asn1.c43
-rw-r--r--src/tls/asn1.h1
-rw-r--r--src/tls/asn1_test.c210
-rw-r--r--src/tls/pkcs1.c201
-rw-r--r--src/tls/pkcs1.h28
-rw-r--r--src/tls/pkcs5.c238
-rw-r--r--src/tls/pkcs5.h22
-rw-r--r--src/tls/pkcs8.c193
-rw-r--r--src/tls/pkcs8.h22
-rw-r--r--src/tls/rsa.c3
-rw-r--r--src/tls/tlsv1_client.c8
-rw-r--r--src/tls/tlsv1_client_read.c6
-rw-r--r--src/tls/tlsv1_client_write.c11
-rw-r--r--src/tls/tlsv1_common.h2
-rw-r--r--src/tls/tlsv1_cred.c83
-rw-r--r--src/tls/tlsv1_record.c4
-rw-r--r--src/tls/tlsv1_record.h2
-rw-r--r--src/tls/tlsv1_server.c8
-rw-r--r--src/tls/tlsv1_server_read.c10
-rw-r--r--src/tls/tlsv1_server_write.c12
-rw-r--r--src/tls/x509v3.c435
-rw-r--r--src/tls/x509v3.h81
-rw-r--r--src/utils/.gitignore1
-rw-r--r--src/utils/Makefile35
-rw-r--r--src/utils/base64.c35
-rw-r--r--src/utils/build_config.h44
-rw-r--r--src/utils/common.c32
-rw-r--r--src/utils/common.h21
-rw-r--r--src/utils/eloop.c242
-rw-r--r--src/utils/eloop.h30
-rw-r--r--src/utils/eloop_none.c11
-rw-r--r--src/utils/eloop_win.c13
-rw-r--r--src/utils/ip_addr.h3
-rw-r--r--src/utils/list.h89
-rw-r--r--src/utils/os.h25
-rw-r--r--src/utils/os_internal.c7
-rw-r--r--src/utils/os_unix.c164
-rw-r--r--src/utils/radiotap.c (renamed from hostapd/radiotap.c)0
-rw-r--r--src/utils/radiotap.h (renamed from src/drivers/radiotap.h)2
-rw-r--r--src/utils/radiotap_iter.h (renamed from hostapd/radiotap_iter.h)0
-rw-r--r--src/utils/trace.c329
-rw-r--r--src/utils/trace.h74
-rw-r--r--src/utils/uuid.c30
-rw-r--r--src/utils/uuid.h1
-rw-r--r--src/utils/wpa_debug.c50
-rw-r--r--src/utils/wpa_debug.h17
-rw-r--r--src/utils/wpabuf.c88
-rw-r--r--src/utils/wpabuf.h6
-rw-r--r--src/wps/Makefile1
-rw-r--r--src/wps/http.h29
-rw-r--r--src/wps/http_client.c371
-rw-r--r--src/wps/http_client.h46
-rw-r--r--src/wps/http_server.c312
-rw-r--r--src/wps/http_server.h39
-rw-r--r--src/wps/httpread.c2
-rw-r--r--src/wps/httpread.h2
-rw-r--r--src/wps/ndef.c175
-rw-r--r--src/wps/upnp_xml.c252
-rw-r--r--src/wps/upnp_xml.h23
-rw-r--r--src/wps/wps.c170
-rw-r--r--src/wps/wps.h233
-rw-r--r--src/wps/wps_attr_build.c80
-rw-r--r--src/wps/wps_attr_parse.c33
-rw-r--r--src/wps/wps_attr_process.c9
-rw-r--r--src/wps/wps_common.c344
-rw-r--r--src/wps/wps_defs.h12
-rw-r--r--src/wps/wps_dev_attr.c28
-rw-r--r--src/wps/wps_enrollee.c51
-rw-r--r--src/wps/wps_er.c1663
-rw-r--r--src/wps/wps_er.h106
-rw-r--r--src/wps/wps_er_ssdp.c198
-rw-r--r--src/wps/wps_i.h34
-rw-r--r--src/wps/wps_nfc.c117
-rw-r--r--src/wps/wps_nfc_pn531.c113
-rw-r--r--src/wps/wps_registrar.c612
-rw-r--r--src/wps/wps_ufd.c235
-rw-r--r--src/wps/wps_upnp.c230
-rw-r--r--src/wps/wps_upnp.h22
-rw-r--r--src/wps/wps_upnp_ap.c80
-rw-r--r--src/wps/wps_upnp_event.c347
-rw-r--r--src/wps/wps_upnp_i.h76
-rw-r--r--src/wps/wps_upnp_ssdp.c125
-rw-r--r--src/wps/wps_upnp_web.c1046
-rw-r--r--wpa_supplicant/.gitignore8
-rw-r--r--wpa_supplicant/ChangeLog162
-rw-r--r--wpa_supplicant/Makefile956
-rw-r--r--wpa_supplicant/README11
-rw-r--r--wpa_supplicant/README-WPS25
-rw-r--r--wpa_supplicant/ap.c481
-rw-r--r--wpa_supplicant/ap.h43
-rw-r--r--wpa_supplicant/bgscan.c110
-rw-r--r--wpa_supplicant/bgscan.h69
-rw-r--r--wpa_supplicant/bgscan_simple.c230
-rw-r--r--wpa_supplicant/bss.c606
-rw-r--r--wpa_supplicant/bss.h93
-rw-r--r--wpa_supplicant/config.c203
-rw-r--r--wpa_supplicant/config.h28
-rw-r--r--wpa_supplicant/config_file.c15
-rw-r--r--wpa_supplicant/config_ssid.h45
-rw-r--r--wpa_supplicant/config_winreg.c15
-rw-r--r--wpa_supplicant/ctrl_iface.c581
-rw-r--r--wpa_supplicant/ctrl_iface_named_pipe.c2
-rw-r--r--wpa_supplicant/ctrl_iface_udp.c2
-rw-r--r--wpa_supplicant/ctrl_iface_unix.c60
-rw-r--r--wpa_supplicant/dbus/.gitignore1
-rw-r--r--wpa_supplicant/dbus/Makefile84
-rw-r--r--wpa_supplicant/dbus/dbus-wpa_supplicant.conf (renamed from wpa_supplicant/dbus-wpa_supplicant.conf)11
-rw-r--r--wpa_supplicant/dbus/dbus_common.c371
-rw-r--r--wpa_supplicant/dbus/dbus_common.h26
-rw-r--r--wpa_supplicant/dbus/dbus_common_i.h30
-rw-r--r--wpa_supplicant/dbus/dbus_dict_helpers.c (renamed from wpa_supplicant/dbus_dict_helpers.c)199
-rw-r--r--wpa_supplicant/dbus/dbus_dict_helpers.h (renamed from wpa_supplicant/dbus_dict_helpers.h)2
-rw-r--r--wpa_supplicant/dbus/dbus_new.c1562
-rw-r--r--wpa_supplicant/dbus/dbus_new.h234
-rw-r--r--wpa_supplicant/dbus/dbus_new_handlers.c2957
-rw-r--r--wpa_supplicant/dbus/dbus_new_handlers.h196
-rw-r--r--wpa_supplicant/dbus/dbus_new_handlers_wps.c331
-rw-r--r--wpa_supplicant/dbus/dbus_new_helpers.c875
-rw-r--r--wpa_supplicant/dbus/dbus_new_helpers.h147
-rw-r--r--wpa_supplicant/dbus/dbus_new_introspect.c278
-rw-r--r--wpa_supplicant/dbus/dbus_old.c (renamed from wpa_supplicant/ctrl_iface_dbus.c)682
-rw-r--r--wpa_supplicant/dbus/dbus_old.h (renamed from wpa_supplicant/ctrl_iface_dbus.h)53
-rw-r--r--wpa_supplicant/dbus/dbus_old_handlers.c (renamed from wpa_supplicant/ctrl_iface_dbus_handlers.c)343
-rw-r--r--wpa_supplicant/dbus/dbus_old_handlers.h (renamed from wpa_supplicant/ctrl_iface_dbus_handlers.h)18
-rw-r--r--wpa_supplicant/dbus/dbus_old_handlers_wps.c161
-rw-r--r--wpa_supplicant/dbus/fi.epitest.hostap.WPASupplicant.service (renamed from wpa_supplicant/dbus-wpa_supplicant.service)0
-rw-r--r--wpa_supplicant/dbus/fi.w1.wpa_supplicant1.service4
-rw-r--r--wpa_supplicant/defconfig55
-rw-r--r--wpa_supplicant/doc/code_structure.doxygen322
-rw-r--r--wpa_supplicant/doc/ctrl_iface.doxygen481
-rw-r--r--wpa_supplicant/doc/docbook/.gitignore6
-rw-r--r--wpa_supplicant/doc/docbook/wpa_background.82
-rw-r--r--wpa_supplicant/doc/docbook/wpa_cli.82
-rw-r--r--wpa_supplicant/doc/docbook/wpa_gui.82
-rw-r--r--wpa_supplicant/doc/docbook/wpa_passphrase.82
-rw-r--r--wpa_supplicant/doc/docbook/wpa_priv.82
-rw-r--r--wpa_supplicant/doc/docbook/wpa_supplicant.818
-rw-r--r--wpa_supplicant/doc/docbook/wpa_supplicant.conf.52
-rw-r--r--wpa_supplicant/doc/docbook/wpa_supplicant.sgml13
-rw-r--r--wpa_supplicant/doc/doxygen.fast239
-rw-r--r--wpa_supplicant/doc/doxygen.full239
-rw-r--r--wpa_supplicant/doc/driver_wrapper.doxygen180
-rw-r--r--wpa_supplicant/doc/eap.doxygen87
-rwxr-xr-xwpa_supplicant/doc/kerneldoc2doxygen.pl134
-rw-r--r--wpa_supplicant/doc/mainpage.doxygen56
-rw-r--r--wpa_supplicant/doc/porting.doxygen208
-rw-r--r--wpa_supplicant/doc/testing_tools.doxygen295
-rw-r--r--wpa_supplicant/doc/wpa_supplicant.fig247
-rw-r--r--wpa_supplicant/driver_i.h494
-rw-r--r--wpa_supplicant/eap_register.c235
-rw-r--r--wpa_supplicant/eapol_test.c50
-rw-r--r--wpa_supplicant/events.c814
-rwxr-xr-xwpa_supplicant/examples/60_wpa_supplicant19
-rwxr-xr-xwpa_supplicant/examples/wpas-dbus-new-getall.py59
-rwxr-xr-xwpa_supplicant/examples/wpas-dbus-new-signals.py203
-rwxr-xr-xwpa_supplicant/examples/wpas-dbus-new-wps.py80
-rwxr-xr-xwpa_supplicant/examples/wpas-dbus-new.py149
-rw-r--r--wpa_supplicant/ibss_rsn.c510
-rw-r--r--wpa_supplicant/ibss_rsn.h49
-rw-r--r--wpa_supplicant/main.c61
-rw-r--r--wpa_supplicant/mlme.c467
-rw-r--r--wpa_supplicant/mlme.h25
-rw-r--r--wpa_supplicant/nmake.mak22
-rw-r--r--wpa_supplicant/notify.c339
-rw-r--r--wpa_supplicant/notify.h81
-rw-r--r--wpa_supplicant/preauth_test.c29
-rw-r--r--wpa_supplicant/scan.c548
-rw-r--r--wpa_supplicant/scan.h37
-rw-r--r--wpa_supplicant/sme.c490
-rw-r--r--wpa_supplicant/sme.h78
-rw-r--r--wpa_supplicant/symbian/wpa_supplicant.mmp4
-rw-r--r--wpa_supplicant/tests/test_aes.c307
-rw-r--r--wpa_supplicant/tests/test_eap_sim_common.c2
-rw-r--r--wpa_supplicant/tests/test_md4.c99
-rw-r--r--wpa_supplicant/tests/test_md5.c99
-rw-r--r--wpa_supplicant/tests/test_ms_funcs.c119
-rw-r--r--wpa_supplicant/tests/test_sha1.c347
-rw-r--r--wpa_supplicant/tests/test_sha256.c331
-rw-r--r--wpa_supplicant/tests/test_wpa.c31
-rw-r--r--wpa_supplicant/tests/test_x509v3.c69
-rwxr-xr-xwpa_supplicant/tests/test_x509v3_nist.sh144
-rwxr-xr-xwpa_supplicant/tests/test_x509v3_nist2.sh165
-rw-r--r--wpa_supplicant/todo.txt15
-rwxr-xr-xwpa_supplicant/vs2005/eapol_test/eapol_test.vcproj54
-rwxr-xr-xwpa_supplicant/vs2005/wpa_cli/wpa_cli.vcproj4
-rwxr-xr-xwpa_supplicant/vs2005/wpa_passphrase/wpa_passphrase.vcproj20
-rwxr-xr-xwpa_supplicant/vs2005/wpa_supplicant/wpa_supplicant.vcproj54
-rwxr-xr-xwpa_supplicant/vs2005/wpasvc/wpasvc.vcproj54
-rw-r--r--wpa_supplicant/wpa_cli.c630
-rw-r--r--wpa_supplicant/wpa_gui-qt4/.gitignore6
-rw-r--r--wpa_supplicant/wpa_gui-qt4/addinterface.cpp20
-rw-r--r--wpa_supplicant/wpa_gui-qt4/eventhistory.cpp4
-rw-r--r--wpa_supplicant/wpa_gui-qt4/icons.qrc2
-rw-r--r--wpa_supplicant/wpa_gui-qt4/icons/Makefile26
-rw-r--r--wpa_supplicant/wpa_gui-qt4/icons/README36
-rw-r--r--wpa_supplicant/wpa_gui-qt4/icons/ap.svg832
-rw-r--r--wpa_supplicant/wpa_gui-qt4/icons/laptop.svg1568
-rw-r--r--wpa_supplicant/wpa_gui-qt4/icons_png.qrc2
-rw-r--r--wpa_supplicant/wpa_gui-qt4/lang/.gitignore1
-rw-r--r--wpa_supplicant/wpa_gui-qt4/lang/wpa_gui_de.ts1262
-rw-r--r--wpa_supplicant/wpa_gui-qt4/main.cpp14
-rw-r--r--wpa_supplicant/wpa_gui-qt4/networkconfig.cpp133
-rw-r--r--wpa_supplicant/wpa_gui-qt4/networkconfig.ui12
-rw-r--r--wpa_supplicant/wpa_gui-qt4/peers.cpp956
-rw-r--r--wpa_supplicant/wpa_gui-qt4/peers.h70
-rw-r--r--wpa_supplicant/wpa_gui-qt4/peers.ui40
-rw-r--r--wpa_supplicant/wpa_gui-qt4/stringquery.cpp37
-rw-r--r--wpa_supplicant/wpa_gui-qt4/stringquery.h34
-rw-r--r--wpa_supplicant/wpa_gui-qt4/userdatarequest.cpp10
-rw-r--r--wpa_supplicant/wpa_gui-qt4/wpa_gui.pro12
-rw-r--r--wpa_supplicant/wpa_gui-qt4/wpagui.cpp338
-rw-r--r--wpa_supplicant/wpa_gui-qt4/wpagui.h3
-rw-r--r--wpa_supplicant/wpa_gui-qt4/wpagui.ui7
-rw-r--r--wpa_supplicant/wpa_gui/.gitignore5
-rw-r--r--wpa_supplicant/wpa_gui/scanresults.ui2
-rw-r--r--wpa_supplicant/wpa_gui/userdatarequest.ui2
-rw-r--r--wpa_supplicant/wpa_gui/wpa_gui.pro2
-rw-r--r--wpa_supplicant/wpa_gui/wpagui.ui2
-rw-r--r--wpa_supplicant/wpa_passphrase.c2
-rw-r--r--wpa_supplicant/wpa_priv.c222
-rw-r--r--wpa_supplicant/wpa_supplicant.c855
-rw-r--r--wpa_supplicant/wpa_supplicant.conf54
-rw-r--r--wpa_supplicant/wpa_supplicant.nsi10
-rw-r--r--wpa_supplicant/wpa_supplicant_i.h521
-rw-r--r--wpa_supplicant/wpas_glue.c105
-rw-r--r--wpa_supplicant/wps_supplicant.c463
-rw-r--r--wpa_supplicant/wps_supplicant.h32
-rw-r--r--wpa_supplicant/xcode/wpa_supplicant.xcodeproj/project.pbxproj513
560 files changed, 63437 insertions, 46402 deletions
diff --git a/hostapd/ChangeLog b/hostapd/ChangeLog
deleted file mode 100644
index 18af4b176b9b..000000000000
--- a/hostapd/ChangeLog
+++ /dev/null
@@ -1,597 +0,0 @@
-ChangeLog for hostapd
-
-2010-01-12 - v0.6.10
- * fixed SHA-256 based key derivation function to match with the
- standard when using CCMP (for IEEE 802.11r and IEEE 802.11w)
- (note: this breaks interoperability with previous version) [Bug 307]
- * fixed WPS selected registrar expiration for internal PIN registrar
- * disable PMTU discovery for RADIUS packets
- * fixed WPS UPnP SSDP on 32-bit targets
- * fixed WPS AP reconfiguration with drivers that do not use hostapd
- MLME
- * fixed RSN parameter setting for multi-BSS case
- * added WPS workarounds for known interoperability issues with broken,
- deployed implementation
- * update IEEE 802.11w implementation to match with the published
- standard
- * fixed OpCode when proxying WSC_ACK or WSC_NACK from WPS ER
- * fixed proxying of WSC_NACK to WPS ER
- * fixed compilation with newer GnuTLS versions
- * added support for defining timeout for WPS PINs
- * fixed WPS Probe Request processing to handle missing required
- attribute
- * fixed PKCS#12 use with OpenSSL 1.0.0
-
-2009-03-23 - v0.6.9
- * driver_nl80211: fixed STA accounting data collection (TX/RX bytes
- reported correctly; TX/RX packets not yet available from kernel)
- * fixed EAPOL/EAP reauthentication when using an external RADIUS
- authentication server
- * driver_prism54: fixed segmentation fault on initialization
- * fixed TNC with EAP-TTLS
- * fixed IEEE 802.11r key derivation function to match with the standard
- (note: this breaks interoperability with previous version) [Bug 303]
-
-2009-02-15 - v0.6.8
- * increased hostapd_cli ping interval to 5 seconds and made this
- configurable with a new command line options (-G<seconds>)
- * driver_nl80211: use Linux socket filter to improve performance
- * added support for external Registrars with WPS (UPnP transport)
-
-2009-01-06 - v0.6.7
- * added support for Wi-Fi Protected Setup (WPS)
- (hostapd can now be configured to act as an integrated WPS Registrar
- and provision credentials for WPS Enrollees using PIN and PBC
- methods; external wireless Registrar can configure the AP, but
- external WLAN Manager Registrars are not supported); WPS support can
- be enabled by adding CONFIG_WPS=y into .config and setting the
- runtime configuration variables in hostapd.conf (see WPS section in
- the example configuration file); new hostapd_cli commands wps_pin and
- wps_pbc are used to configure WPS negotiation; see README-WPS for
- more details
- * added IEEE 802.11n HT capability configuration (ht_capab)
- * added support for generating Country IE based on nl80211 regulatory
- information (added if ieee80211d=1 in configuration)
- * fixed WEP authentication (both Open System and Shared Key) with
- mac80211
- * added support for EAP-AKA' (draft-arkko-eap-aka-kdf)
- * added support for using driver_test over UDP socket
- * changed EAP-GPSK to use the IANA assigned EAP method type 51
- * updated management frame protection to use IEEE 802.11w/D7.0
- * fixed retransmission of EAP requests if no response is received
-
-2008-11-23 - v0.6.6
- * added a new configuration option, wpa_ptk_rekey, that can be used to
- enforce frequent PTK rekeying, e.g., to mitigate some attacks against
- TKIP deficiencies
- * updated OpenSSL code for EAP-FAST to use an updated version of the
- session ticket overriding API that was included into the upstream
- OpenSSL 0.9.9 tree on 2008-11-15 (no additional OpenSSL patch is
- needed with that version anymore)
- * changed channel flags configuration to read the information from
- the driver (e.g., via driver_nl80211 when using mac80211) instead of
- using hostapd as the source of the regulatory information (i.e.,
- information from CRDA is now used with mac80211); this allows 5 GHz
- channels to be used with hostapd (if allowed in the current
- regulatory domain)
- * fixed EAP-TLS message processing for the last TLS message if it is
- large enough to require fragmentation (e.g., if a large Session
- Ticket data is included)
- * fixed listen interval configuration for nl80211 drivers
-
-2008-11-01 - v0.6.5
- * added support for SHA-256 as X.509 certificate digest when using the
- internal X.509/TLSv1 implementation
- * fixed EAP-FAST PAC-Opaque padding (0.6.4 broke this for some peer
- identity lengths)
- * fixed internal TLSv1 implementation for abbreviated handshake (used
- by EAP-FAST server)
- * added support for setting VLAN ID for STAs based on local MAC ACL
- (accept_mac_file) as an alternative for RADIUS server-based
- configuration
- * updated management frame protection to use IEEE 802.11w/D6.0
- (adds a new association ping to protect against unauthenticated
- authenticate or (re)associate request frames dropping association)
- * added support for using SHA256-based stronger key derivation for WPA2
- (IEEE 802.11w)
- * added new "driver wrapper" for RADIUS-only configuration
- (driver=none in hostapd.conf; CONFIG_DRIVER_NONE=y in .config)
- * fixed WPA/RSN IE validation to verify that the proto (WPA vs. WPA2)
- is enabled in configuration
- * changed EAP-FAST configuration to use separate fields for A-ID and
- A-ID-Info (eap_fast_a_id_info) to allow A-ID to be set to a fixed
- 16-octet len binary value for better interoperability with some peer
- implementations; eap_fast_a_id is now configured as a hex string
- * driver_nl80211: Updated to match the current Linux mac80211 AP mode
- configuration (wireless-testing.git and Linux kernel releases
- starting from 2.6.29)
-
-2008-08-10 - v0.6.4
- * added peer identity into EAP-FAST PAC-Opaque and skip Phase 2
- Identity Request if identity is already known
- * added support for EAP Sequences in EAP-FAST Phase 2
- * added support for EAP-TNC (Trusted Network Connect)
- (this version implements the EAP-TNC method and EAP-TTLS/EAP-FAST
- changes needed to run two methods in sequence (IF-T) and the IF-IMV
- and IF-TNCCS interfaces from TNCS)
- * added support for optional cryptobinding with PEAPv0
- * added fragmentation support for EAP-TNC
- * added support for fragmenting EAP-TTLS/PEAP/FAST Phase 2 (tunneled)
- data
- * added support for opportunistic key caching (OKC)
-
-2008-02-22 - v0.6.3
- * fixed Reassociation Response callback processing when using internal
- MLME (driver_{hostap,nl80211,test}.c)
- * updated FT support to use the latest draft, IEEE 802.11r/D9.0
- * copy optional Proxy-State attributes into RADIUS response when acting
- as a RADIUS authentication server
- * fixed EAPOL state machine to handle a case in which no response is
- received from the RADIUS authentication server; previous version
- could have triggered a crash in some cases after a timeout
- * fixed EAP-SIM/AKA realm processing to allow decorated usernames to
- be used
- * added a workaround for EAP-SIM/AKA peers that include incorrect null
- termination in the username
- * fixed EAP-SIM/AKA protected result indication to include AT_COUNTER
- attribute in notification messages only when using fast
- reauthentication
- * fixed EAP-SIM Start response processing for fast reauthentication
- case
- * added support for pending EAP processing in EAP-{PEAP,TTLS,FAST}
- phase 2 to allow EAP-SIM and EAP-AKA to be used as the Phase 2 method
-
-2008-01-01 - v0.6.2
- * fixed EAP-SIM and EAP-AKA message parser to validate attribute
- lengths properly to avoid potential crash caused by invalid messages
- * added data structure for storing allocated buffers (struct wpabuf);
- this does not affect hostapd usage, but many of the APIs changed
- and various interfaces (e.g., EAP) is not compatible with old
- versions
- * added support for protecting EAP-AKA/Identity messages with
- AT_CHECKCODE (optional feature in RFC 4187)
- * added support for protected result indication with AT_RESULT_IND for
- EAP-SIM and EAP-AKA (eap_sim_aka_result_ind=1)
- * added support for configuring EAP-TTLS phase 2 non-EAP methods in
- EAP server configuration; previously all four were enabled for every
- phase 2 user, now all four are disabled by default and need to be
- enabled with new method names TTLS-PAP, TTLS-CHAP, TTLS-MSCHAP,
- TTLS-MSCHAPV2
- * removed old debug printing mechanism and the related 'debug'
- parameter in the configuration file; debug verbosity is now set with
- -d (or -dd) command line arguments
- * added support for EAP-IKEv2 (draft-tschofenig-eap-ikev2-15.txt);
- only shared key/password authentication is supported in this version
-
-2007-11-24 - v0.6.1
- * added experimental, integrated TLSv1 server implementation with the
- needed X.509/ASN.1/RSA/bignum processing (this can be enabled by
- setting CONFIG_TLS=internal and CONFIG_INTERNAL_LIBTOMMATH=y in
- .config); this can be useful, e.g., if the target system does not
- have a suitable TLS library and a minimal code size is required
- * added support for EAP-FAST server method to the integrated EAP
- server
- * updated EAP Generalized Pre-Shared Key (EAP-GPSK) to use the latest
- draft (draft-ietf-emu-eap-gpsk-07.txt)
- * added a new configuration parameter, rsn_pairwise, to allow different
- pairwise cipher suites to be enabled for WPA and RSN/WPA2
- (note: if wpa_pairwise differs from rsn_pairwise, the driver will
- either need to support this or will have to use the WPA/RSN IEs from
- hostapd; currently, the included madwifi and bsd driver interfaces do
- not have support for this)
- * updated FT support to use the latest draft, IEEE 802.11r/D8.0
-
-2007-05-28 - v0.6.0
- * added experimental IEEE 802.11r/D6.0 support
- * updated EAP-SAKE to RFC 4763 and the IANA-allocated EAP type 48
- * updated EAP-PSK to use the IANA-allocated EAP type 47
- * fixed EAP-PSK bit ordering of the Flags field
- * fixed configuration reloading (SIGHUP) to re-initialize WPA PSKs
- by reading wpa_psk_file [Bug 181]
- * fixed EAP-TTLS AVP parser processing for too short AVP lengths
- * fixed IPv6 connection to RADIUS accounting server
- * updated EAP Generalized Pre-Shared Key (EAP-GPSK) to use the latest
- draft (draft-ietf-emu-eap-gpsk-04.txt)
- * hlr_auc_gw: read GSM triplet file into memory and rotate through the
- entries instead of only using the same three triplets every time
- (this does not work properly with tests using multiple clients, but
- provides bit better triplet data for testing a single client; anyway,
- if a better quality triplets are needed, GSM-Milenage should be used
- instead of hardcoded triplet file)
- * fixed EAP-MSCHAPv2 server to use a space between S and M parameters
- in Success Request [Bug 203]
- * added support for sending EAP-AKA Notifications in error cases
- * updated to use IEEE 802.11w/D2.0 for management frame protection
- (still experimental)
- * RADIUS server: added support for processing duplicate messages
- (retransmissions from RADIUS client) by replying with the previous
- reply
-
-2006-11-24 - v0.5.6
- * added support for configuring and controlling multiple BSSes per
- radio interface (bss=<ifname> in hostapd.conf); this is only
- available with Devicescape and test driver interfaces
- * fixed PMKSA cache update in the end of successful RSN
- pre-authentication
- * added support for dynamic VLAN configuration (i.e., selecting VLAN-ID
- for each STA based on RADIUS Access-Accept attributes); this requires
- VLAN support from the kernel driver/802.11 stack and this is
- currently only available with Devicescape and test driver interfaces
- * driver_madwifi: fixed configuration of unencrypted modes (plaintext
- and IEEE 802.1X without WEP)
- * removed STAKey handshake since PeerKey handshake has replaced it in
- IEEE 802.11ma and there are no known deployments of STAKey
- * updated EAP Generalized Pre-Shared Key (EAP-GPSK) to use the latest
- draft (draft-ietf-emu-eap-gpsk-01.txt)
- * added preliminary implementation of IEEE 802.11w/D1.0 (management
- frame protection)
- (Note: this requires driver support to work properly.)
- (Note2: IEEE 802.11w is an unapproved draft and subject to change.)
- * hlr_auc_gw: added support for GSM-Milenage (for EAP-SIM)
- * hlr_auc_gw: added support for reading per-IMSI Milenage keys and
- parameters from a text file to make it possible to implement proper
- GSM/UMTS authentication server for multiple SIM/USIM cards using
- EAP-SIM/EAP-AKA
- * fixed session timeout processing with drivers that do not use
- ieee802_11.c (e.g., madwifi)
-
-2006-08-27 - v0.5.5
- * added 'hostapd_cli new_sta <addr>' command for adding a new STA into
- hostapd (e.g., to initialize wired network authentication based on an
- external signal)
- * fixed hostapd to add PMKID KDE into 4-Way Handshake Message 1 when
- using WPA2 even if PMKSA caching is not used
- * added -P<pid file> argument for hostapd to write the current process
- id into a file
- * added support for RADIUS Authentication Server MIB (RFC 2619)
-
-2006-06-20 - v0.5.4
- * fixed nt_password_hash build [Bug 144]
- * added PeerKey handshake implementation for IEEE 802.11e
- direct link setup (DLS) to replace STAKey handshake
- * added support for EAP Generalized Pre-Shared Key (EAP-GPSK,
- draft-clancy-emu-eap-shared-secret-00.txt)
- * fixed a segmentation fault when RSN pre-authentication was completed
- successfully [Bug 152]
-
-2006-04-27 - v0.5.3
- * do not build nt_password_hash and hlr_auc_gw by default to avoid
- requiring a TLS library for a successful build; these programs can be
- build with 'make nt_password_hash' and 'make hlr_auc_gw'
- * added a new configuration option, eapol_version, that can be used to
- set EAPOL version to 1 (default is 2) to work around broken client
- implementations that drop EAPOL frames which use version number 2
- [Bug 89]
- * added support for EAP-SAKE (no EAP method number allocated yet, so
- this is using the same experimental type 255 as EAP-PSK)
- * fixed EAP-MSCHAPv2 message length validation
-
-2006-03-19 - v0.5.2
- * fixed stdarg use in hostapd_logger(): if both stdout and syslog
- logging was enabled, hostapd could trigger a segmentation fault in
- vsyslog on some CPU -- C library combinations
- * moved HLR/AuC gateway implementation for EAP-SIM/AKA into an external
- program to make it easier to use for implementing real SS7 gateway;
- eap_sim_db is not anymore used as a file name for GSM authentication
- triplets; instead, it is path to UNIX domain socket that will be used
- to communicate with the external gateway program (e.g., hlr_auc_gw)
- * added example HLR/AuC gateway implementation, hlr_auc_gw, that uses
- local information (GSM authentication triplets from a text file and
- hardcoded AKA authentication data); this can be used to test EAP-SIM
- and EAP-AKA
- * added Milenage algorithm (example 3GPP AKA algorithm) to hlr_auc_gw
- to make it possible to test EAP-AKA with real USIM cards (this is
- disabled by default; define AKA_USE_MILENAGE when building hlr_auc_gw
- to enable this)
- * driver_madwifi: added support for getting station RSN IE from
- madwifi-ng svn r1453 and newer; this fixes RSN that was apparently
- broken with earlier change (r1357) in the driver
- * changed EAP method registration to use a dynamic list of methods
- instead of a static list generated at build time
- * fixed WPA message 3/4 not to encrypt Key Data field (WPA IE)
- [Bug 125]
- * added ap_max_inactivity configuration parameter
-
-2006-01-29 - v0.5.1
- * driver_test: added better support for multiple APs and STAs by using
- a directory with sockets that include MAC address for each device in
- the name (test_socket=DIR:/tmp/test)
- * added support for EAP expanded type (vendor specific EAP methods)
-
-2005-12-18 - v0.5.0 (beginning of 0.5.x development releases)
- * added experimental STAKey handshake implementation for IEEE 802.11e
- direct link setup (DLS); note: this is disabled by default in both
- build and runtime configuration (can be enabled with CONFIG_STAKEY=y
- and stakey=1)
- * added support for EAP methods to use callbacks to external programs
- by buffering a pending request and processing it after the EAP method
- is ready to continue
- * improved EAP-SIM database interface to allow external request to GSM
- HLR/AuC without blocking hostapd process
- * added support for using EAP-SIM pseudonyms and fast re-authentication
- * added support for EAP-AKA in the integrated EAP authenticator
- * added support for matching EAP identity prefixes (e.g., "1"*) in EAP
- user database to allow EAP-SIM/AKA selection without extra roundtrip
- for EAP-Nak negotiation
- * added support for storing EAP user password as NtPasswordHash instead
- of plaintext password when using MSCHAP or MSCHAPv2 for
- authentication (hash:<16-octet hex value>); added nt_password_hash
- tool for hashing password to generate NtPasswordHash
-
-2005-11-20 - v0.4.7 (beginning of 0.4.x stable releases)
- * driver_wired: fixed EAPOL sending to optionally use PAE group address
- as the destination instead of supplicant MAC address; this is
- disabled by default, but should be enabled with use_pae_group_addr=1
- in configuration file if the wired interface is used by only one
- device at the time (common switch configuration)
- * driver_madwifi: configure driver to use TKIP countermeasures in order
- to get correct behavior (IEEE 802.11 association failing; previously,
- association succeeded, but hostpad forced disassociation immediately)
- * driver_madwifi: added support for madwifi-ng
-
-2005-10-27 - v0.4.6
- * added support for replacing user identity from EAP with RADIUS
- User-Name attribute from Access-Accept message, if that is included,
- for the RADIUS accounting messages (e.g., for EAP-PEAP/TTLS to get
- tunneled identity into accounting messages when the RADIUS server
- does not support better way of doing this with Class attribute)
- * driver_madwifi: fixed EAPOL packet receive for configuration where
- ath# is part of a bridge interface
- * added a configuration file and log analyzer script for logwatch
- * fixed EAPOL state machine step function to process all state
- transitions before processing new events; this resolves a race
- condition in which EAPOL-Start message could trigger hostapd to send
- two EAP-Response/Identity frames to the authentication server
-
-2005-09-25 - v0.4.5
- * added client CA list to the TLS certificate request in order to make
- it easier for the client to select which certificate to use
- * added experimental support for EAP-PSK
- * added support for WE-19 (hostap, madwifi)
-
-2005-08-21 - v0.4.4
- * fixed build without CONFIG_RSN_PREAUTH
- * fixed FreeBSD build
-
-2005-06-26 - v0.4.3
- * fixed PMKSA caching to copy User-Name and Class attributes so that
- RADIUS accounting gets correct information
- * start RADIUS accounting only after successful completion of WPA
- 4-Way Handshake if WPA-PSK is used
- * fixed PMKSA caching for the case where STA (re)associates without
- first disassociating
-
-2005-06-12 - v0.4.2
- * EAP-PAX is now registered as EAP type 46
- * fixed EAP-PAX MAC calculation
- * fixed EAP-PAX CK and ICK key derivation
- * renamed eap_authenticator configuration variable to eap_server to
- better match with RFC 3748 (EAP) terminology
- * driver_test: added support for testing hostapd with wpa_supplicant
- by using test driver interface without any kernel drivers or network
- cards
-
-2005-05-22 - v0.4.1
- * fixed RADIUS server initialization when only auth or acct server
- is configured and the other one is left empty
- * driver_madwifi: added support for RADIUS accounting
- * driver_madwifi: added preliminary support for compiling against 'BSD'
- branch of madwifi CVS tree
- * driver_madwifi: fixed pairwise key removal to allow WPA reauth
- without disassociation
- * added support for reading additional certificates from PKCS#12 files
- and adding them to the certificate chain
- * fixed RADIUS Class attribute processing to only use Access-Accept
- packets to update Class; previously, other RADIUS authentication
- packets could have cleared Class attribute
- * added support for more than one Class attribute in RADIUS packets
- * added support for verifying certificate revocation list (CRL) when
- using integrated EAP authenticator for EAP-TLS; new hostapd.conf
- options 'check_crl'; CRL must be included in the ca_cert file for now
-
-2005-04-25 - v0.4.0 (beginning of 0.4.x development releases)
- * added support for including network information into
- EAP-Request/Identity message (ASCII-0 (nul) in eap_message)
- (e.g., to implement draft-adrange-eap-network-discovery-07.txt)
- * fixed a bug which caused some RSN pre-authentication cases to use
- freed memory and potentially crash hostapd
- * fixed private key loading for cases where passphrase is not set
- * added support for sending TLS alerts and aborting authentication
- when receiving a TLS alert
- * fixed WPA2 to add PMKSA cache entry when using integrated EAP
- authenticator
- * fixed PMKSA caching (EAP authentication was not skipped correctly
- with the new state machine changes from IEEE 802.1X draft)
- * added support for RADIUS over IPv6; own_ip_addr, auth_server_addr,
- and acct_server_addr can now be IPv6 addresses (CONFIG_IPV6=y needs
- to be added to .config to include IPv6 support); for RADIUS server,
- radius_server_ipv6=1 needs to be set in hostapd.conf and addresses
- in RADIUS clients file can then use IPv6 format
- * added experimental support for EAP-PAX
- * replaced hostapd control interface library (hostapd_ctrl.[ch]) with
- the same implementation that wpa_supplicant is using (wpa_ctrl.[ch])
-
-2005-02-12 - v0.3.7 (beginning of 0.3.x stable releases)
-
-2005-01-23 - v0.3.5
- * added support for configuring a forced PEAP version based on the
- Phase 1 identity
- * fixed PEAPv1 to use tunneled EAP-Success/Failure instead of EAP-TLV
- to terminate authentication
- * fixed EAP identifier duplicate processing with the new IEEE 802.1X
- draft
- * clear accounting data in the driver when starting a new accounting
- session
- * driver_madwifi: filter wireless events based on ifindex to allow more
- than one network interface to be used
- * fixed WPA message 2/4 processing not to cancel timeout for TimeoutEvt
- setting if the packet does not pass MIC verification (e.g., due to
- incorrect PSK); previously, message 1/4 was not tried again if an
- invalid message 2/4 was received
- * fixed reconfiguration of RADIUS client retransmission timer when
- adding a new message to the pending list; previously, timer was not
- updated at this point and if there was a pending message with long
- time for the next retry, the new message needed to wait that long for
- its first retry, too
-
-2005-01-09 - v0.3.4
- * added support for configuring multiple allowed EAP types for Phase 2
- authentication (EAP-PEAP, EAP-TTLS)
- * fixed EAPOL-Start processing to trigger WPA reauthentication
- (previously, only EAPOL authentication was done)
-
-2005-01-02 - v0.3.3
- * added support for EAP-PEAP in the integrated EAP authenticator
- * added support for EAP-GTC in the integrated EAP authenticator
- * added support for configuring list of EAP methods for Phase 1 so that
- the integrated EAP authenticator can, e.g., use the wildcard entry
- for EAP-TLS and EAP-PEAP
- * added support for EAP-TTLS in the integrated EAP authenticator
- * added support for EAP-SIM in the integrated EAP authenticator
- * added support for using hostapd as a RADIUS authentication server
- with the integrated EAP authenticator taking care of EAP
- authentication (new hostapd.conf options: radius_server_clients and
- radius_server_auth_port); this is not included in default build; use
- CONFIG_RADIUS_SERVER=y in .config to include
-
-2004-12-19 - v0.3.2
- * removed 'daemonize' configuration file option since it has not really
- been used at all for more than year
- * driver_madwifi: fixed group key setup and added get_ssid method
- * added support for EAP-MSCHAPv2 in the integrated EAP authenticator
-
-2004-12-12 - v0.3.1
- * added support for integrated EAP-TLS authentication (new hostapd.conf
- variables: ca_cert, server_cert, private_key, private_key_passwd);
- this enabled dynamic keying (WPA2/WPA/IEEE 802.1X/WEP) without
- external RADIUS server
- * added support for reading PKCS#12 (PFX) files (as a replacement for
- PEM/DER) to get certificate and private key (CONFIG_PKCS12)
-
-2004-12-05 - v0.3.0 (beginning of 0.3.x development releases)
- * added support for Acct-{Input,Output}-Gigawords
- * added support for Event-Timestamp (in RADIUS Accounting-Requests)
- * added support for RADIUS Authentication Client MIB (RFC2618)
- * added support for RADIUS Accounting Client MIB (RFC2620)
- * made EAP re-authentication period configurable (eap_reauth_period)
- * fixed EAPOL reauthentication to trigger WPA/WPA2 reauthentication
- * fixed EAPOL state machine to stop if STA is removed during
- eapol_sm_step(); this fixes at least one segfault triggering bug with
- IEEE 802.11i pre-authentication
- * added support for multiple WPA pre-shared keys (e.g., one for each
- client MAC address or keys shared by a group of clients);
- new hostapd.conf field wpa_psk_file for setting path to a text file
- containing PSKs, see hostapd.wpa_psk for an example
- * added support for multiple driver interfaces to allow hostapd to be
- used with other drivers
- * added wired authenticator driver interface (driver=wired in
- hostapd.conf, see wired.conf for example configuration)
- * added madwifi driver interface (driver=madwifi in hostapd.conf, see
- madwifi.conf for example configuration; Note: include files from
- madwifi project is needed for building and a configuration file,
- .config, needs to be created in hostapd directory with
- CONFIG_DRIVER_MADWIFI=y to include this driver interface in hostapd
- build)
- * fixed an alignment issue that could cause SHA-1 to fail on some
- platforms (e.g., Intel ixp425 with a compiler that does not 32-bit
- align variables)
- * fixed RADIUS reconnection after an error in sending interim
- accounting packets
- * added hostapd control interface for external programs and an example
- CLI, hostapd_cli (like wpa_cli for wpa_supplicant)
- * started adding dot11, dot1x, radius MIBs ('hostapd_cli mib',
- 'hostapd_cli sta <addr>')
- * finished update from IEEE 802.1X-2001 to IEEE 802.1X-REV (now d11)
- * added support for strict GTK rekeying (wpa_strict_rekey in
- hostapd.conf)
- * updated IAPP to use UDP port 3517 and multicast address 224.0.1.178
- (instead of broadcast) for IAPP ADD-notify (moved from draft 3 to
- IEEE 802.11F-2003)
- * added Prism54 driver interface (driver=prism54 in hostapd.conf;
- note: .config needs to be created in hostapd directory with
- CONFIG_DRIVER_PRISM54=y to include this driver interface in hostapd
- build)
- * dual-licensed hostapd (GPLv2 and BSD licenses)
- * fixed RADIUS accounting to generate a new session id for cases where
- a station reassociates without first being complete deauthenticated
- * fixed STA disassociation handler to mark next timeout state to
- deauthenticate the station, i.e., skip long wait for inactivity poll
- and extra disassociation, if the STA disassociates without
- deauthenticating
- * added integrated EAP authenticator that can be used instead of
- external RADIUS authentication server; currently, only EAP-MD5 is
- supported, so this cannot yet be used for key distribution; the EAP
- method interface is generic, though, so adding new EAP methods should
- be straightforward; new hostapd.conf variables: 'eap_authenticator'
- and 'eap_user_file'; this obsoletes "minimal authentication server"
- ('minimal_eap' in hostapd.conf) which is now removed
- * added support for FreeBSD and driver interface for the BSD net80211
- layer (driver=bsd in hostapd.conf and CONFIG_DRIVER_BSD=y in
- .config); please note that some of the required kernel mods have not
- yet been committed
-
-2004-07-17 - v0.2.4 (beginning of 0.2.x stable releases)
- * fixed some accounting cases where Accounting-Start was sent when
- IEEE 802.1X port was being deauthorized
-
-2004-06-20 - v0.2.3
- * modified RADIUS client to re-connect the socket in case of certain
- error codes that are generated when a network interface state is
- changes (e.g., when IP address changes or the interface is set UP)
- * fixed couple of cases where EAPOL state for a station was freed
- twice causing a segfault for hostapd
- * fixed couple of bugs in processing WPA deauthentication (freed data
- was used)
-
-2004-05-31 - v0.2.2
- * fixed WPA/WPA2 group rekeying to use key index correctly (GN/GM)
- * fixed group rekeying to send zero TSC in EAPOL-Key messages to fix
- cases where STAs dropped multicast frames as replay attacks
- * added support for copying RADIUS Attribute 'Class' from
- authentication messages into accounting messages
- * send canned EAP failure if RADIUS server sends Access-Reject without
- EAP message (previously, Supplicant was not notified in this case)
- * fixed mixed WPA-PSK and WPA-EAP mode to work with WPA-PSK (i.e., do
- not start EAPOL state machines if the STA selected to use WPA-PSK)
-
-2004-05-06 - v0.2.1
- * added WPA and IEEE 802.11i/RSN (WPA2) Authenticator functionality
- - based on IEEE 802.11i/D10.0 but modified to interoperate with WPA
- (i.e., IEEE 802.11i/D3.0)
- - supports WPA-only, RSN-only, and mixed WPA/RSN mode
- - both WPA-PSK and WPA-RADIUS/EAP are supported
- - PMKSA caching and pre-authentication
- - new hostapd.conf variables: wpa, wpa_psk, wpa_passphrase,
- wpa_key_mgmt, wpa_pairwise, wpa_group_rekey, wpa_gmk_rekey,
- rsn_preauth, rsn_preauth_interfaces
- * fixed interim accounting to remove any pending accounting messages
- to the STA before sending a new one
-
-2004-02-15 - v0.2.0
- * added support for Acct-Interim-Interval:
- - draft-ietf-radius-acct-interim-01.txt
- - use Acct-Interim-Interval attribute from Access-Accept if local
- 'radius_acct_interim_interval' is not set
- - allow different update intervals for each STA
- * fixed event loop to call signal handlers only after returning from
- the real signal handler
- * reset sta->timeout_next after successful association to make sure
- that the previously registered inactivity timer will not remove the
- STA immediately (e.g., if STA deauthenticates and re-associates
- before the timer is triggered).
- * added new hostapd.conf variable, nas_identifier, that can be used to
- add an optional RADIUS Attribute, NAS-Identifier, into authentication
- and accounting messages
- * added support for Accounting-On and Accounting-Off messages
- * fixed accounting session handling to send Accounting-Start only once
- per session and not to send Accounting-Stop if the session was not
- initialized properly
- * fixed Accounting-Stop statistics in cases where the message was
- previously sent after the kernel entry for the STA (and/or IEEE
- 802.1X data) was removed
-
-
-Note:
-
-Older changes up to and including v0.1.0 are included in the ChangeLog
-of the Host AP driver.
diff --git a/hostapd/Makefile b/hostapd/Makefile
deleted file mode 100644
index 3b3d7feb58c0..000000000000
--- a/hostapd/Makefile
+++ /dev/null
@@ -1,635 +0,0 @@
-ifndef CC
-CC=gcc
-endif
-
-ifndef CFLAGS
-CFLAGS = -MMD -O2 -Wall -g
-endif
-
-# define HOSTAPD_DUMP_STATE to include SIGUSR1 handler for dumping state to
-# a file (undefine it, if you want to save in binary size)
-CFLAGS += -DHOSTAPD_DUMP_STATE
-
-CFLAGS += -I../src
-CFLAGS += -I../src/crypto
-CFLAGS += -I../src/utils
-CFLAGS += -I../src/common
-
-# Uncomment following line and set the path to your kernel tree include
-# directory if your C library does not include all header files.
-# CFLAGS += -DUSE_KERNEL_HEADERS -I/usr/src/linux/include
-
--include .config
-
-ifndef CONFIG_OS
-ifdef CONFIG_NATIVE_WINDOWS
-CONFIG_OS=win32
-else
-CONFIG_OS=unix
-endif
-endif
-
-ifeq ($(CONFIG_OS), internal)
-CFLAGS += -DOS_NO_C_LIB_DEFINES
-endif
-
-ifdef CONFIG_NATIVE_WINDOWS
-CFLAGS += -DCONFIG_NATIVE_WINDOWS
-LIBS += -lws2_32
-endif
-
-OBJS = hostapd.o ieee802_1x.o eapol_sm.o \
- ieee802_11.o config.o ieee802_11_auth.o accounting.o \
- sta_info.o wpa.o ctrl_iface.o \
- drivers.o preauth.o pmksa_cache.o beacon.o \
- hw_features.o wme.o ap_list.o \
- mlme.o vlan_init.o wpa_auth_ie.o
-
-OBJS += ../src/utils/eloop.o
-OBJS += ../src/utils/common.o
-OBJS += ../src/utils/wpa_debug.o
-OBJS += ../src/utils/wpabuf.o
-OBJS += ../src/utils/os_$(CONFIG_OS).o
-OBJS += ../src/utils/ip_addr.o
-
-OBJS += ../src/common/ieee802_11_common.o
-OBJS += ../src/common/wpa_common.o
-
-OBJS += ../src/radius/radius.o
-OBJS += ../src/radius/radius_client.o
-
-OBJS += ../src/crypto/md5.o
-OBJS += ../src/crypto/rc4.o
-OBJS += ../src/crypto/md4.o
-OBJS += ../src/crypto/sha1.o
-OBJS += ../src/crypto/des.o
-OBJS += ../src/crypto/aes_wrap.o
-OBJS += ../src/crypto/aes.o
-
-HOBJS=../src/hlr_auc_gw/hlr_auc_gw.o ../src/utils/common.o ../src/utils/wpa_debug.o ../src/utils/os_$(CONFIG_OS).o ../src/hlr_auc_gw/milenage.o ../src/crypto/aes_wrap.o ../src/crypto/aes.o
-
-CFLAGS += -DCONFIG_CTRL_IFACE -DCONFIG_CTRL_IFACE_UNIX
-
-ifdef CONFIG_IAPP
-CFLAGS += -DCONFIG_IAPP
-OBJS += iapp.o
-endif
-
-ifdef CONFIG_RSN_PREAUTH
-CFLAGS += -DCONFIG_RSN_PREAUTH
-CONFIG_L2_PACKET=y
-endif
-
-ifdef CONFIG_PEERKEY
-CFLAGS += -DCONFIG_PEERKEY
-OBJS += peerkey.o
-endif
-
-ifdef CONFIG_IEEE80211W
-CFLAGS += -DCONFIG_IEEE80211W
-NEED_SHA256=y
-endif
-
-ifdef CONFIG_IEEE80211R
-CFLAGS += -DCONFIG_IEEE80211R
-OBJS += wpa_ft.o
-NEED_SHA256=y
-endif
-
-ifdef CONFIG_IEEE80211N
-CFLAGS += -DCONFIG_IEEE80211N
-endif
-
-ifdef CONFIG_DRIVER_HOSTAP
-CFLAGS += -DCONFIG_DRIVER_HOSTAP
-OBJS += driver_hostap.o
-endif
-
-ifdef CONFIG_DRIVER_WIRED
-CFLAGS += -DCONFIG_DRIVER_WIRED
-OBJS += driver_wired.o
-endif
-
-ifdef CONFIG_DRIVER_MADWIFI
-CFLAGS += -DCONFIG_DRIVER_MADWIFI
-OBJS += driver_madwifi.o
-CONFIG_L2_PACKET=y
-endif
-
-ifdef CONFIG_DRIVER_ATHEROS
-CFLAGS += -DCONFIG_DRIVER_ATHEROS
-OBJS += driver_atheros.o
-CONFIG_L2_PACKET=y
-endif
-
-ifdef CONFIG_DRIVER_PRISM54
-CFLAGS += -DCONFIG_DRIVER_PRISM54
-OBJS += driver_prism54.o
-endif
-
-ifdef CONFIG_DRIVER_NL80211
-CFLAGS += -DCONFIG_DRIVER_NL80211
-OBJS += driver_nl80211.o radiotap.o
-LIBS += -lnl
-ifdef CONFIG_LIBNL20
-LIBS += -lnl-genl
-CFLAGS += -DCONFIG_LIBNL20
-endif
-endif
-
-ifdef CONFIG_DRIVER_BSD
-CFLAGS += -DCONFIG_DRIVER_BSD
-OBJS += driver_bsd.o
-CONFIG_L2_PACKET=y
-CONFIG_DNET_PCAP=y
-CONFIG_L2_FREEBSD=y
-endif
-
-ifdef CONFIG_DRIVER_TEST
-CFLAGS += -DCONFIG_DRIVER_TEST
-OBJS += driver_test.o
-endif
-
-ifdef CONFIG_DRIVER_NONE
-CFLAGS += -DCONFIG_DRIVER_NONE
-OBJS += driver_none.o
-endif
-
-ifdef CONFIG_L2_PACKET
-ifdef CONFIG_DNET_PCAP
-ifdef CONFIG_L2_FREEBSD
-LIBS += -lpcap
-OBJS += ../src/l2_packet/l2_packet_freebsd.o
-else
-LIBS += -ldnet -lpcap
-OBJS += ../src/l2_packet/l2_packet_pcap.o
-endif
-else
-OBJS += ../src/l2_packet/l2_packet_linux.o
-endif
-else
-OBJS += ../src/l2_packet/l2_packet_none.o
-endif
-
-
-ifdef CONFIG_EAP_MD5
-CFLAGS += -DEAP_MD5
-OBJS += ../src/eap_server/eap_md5.o
-CHAP=y
-endif
-
-ifdef CONFIG_EAP_TLS
-CFLAGS += -DEAP_TLS
-OBJS += ../src/eap_server/eap_tls.o
-TLS_FUNCS=y
-endif
-
-ifdef CONFIG_EAP_PEAP
-CFLAGS += -DEAP_PEAP
-OBJS += ../src/eap_server/eap_peap.o
-OBJS += ../src/eap_common/eap_peap_common.o
-TLS_FUNCS=y
-CONFIG_EAP_MSCHAPV2=y
-endif
-
-ifdef CONFIG_EAP_TTLS
-CFLAGS += -DEAP_TTLS
-OBJS += ../src/eap_server/eap_ttls.o
-TLS_FUNCS=y
-CHAP=y
-endif
-
-ifdef CONFIG_EAP_MSCHAPV2
-CFLAGS += -DEAP_MSCHAPv2
-OBJS += ../src/eap_server/eap_mschapv2.o
-MS_FUNCS=y
-endif
-
-ifdef CONFIG_EAP_GTC
-CFLAGS += -DEAP_GTC
-OBJS += ../src/eap_server/eap_gtc.o
-endif
-
-ifdef CONFIG_EAP_SIM
-CFLAGS += -DEAP_SIM
-OBJS += ../src/eap_server/eap_sim.o
-CONFIG_EAP_SIM_COMMON=y
-endif
-
-ifdef CONFIG_EAP_AKA
-CFLAGS += -DEAP_AKA
-OBJS += ../src/eap_server/eap_aka.o
-CONFIG_EAP_SIM_COMMON=y
-NEED_SHA256=y
-endif
-
-ifdef CONFIG_EAP_AKA_PRIME
-CFLAGS += -DEAP_AKA_PRIME
-endif
-
-ifdef CONFIG_EAP_SIM_COMMON
-OBJS += ../src/eap_common/eap_sim_common.o
-# Example EAP-SIM/AKA interface for GSM/UMTS authentication. This can be
-# replaced with another file implementating the interface specified in
-# eap_sim_db.h.
-OBJS += ../src/eap_server/eap_sim_db.o
-NEED_FIPS186_2_PRF=y
-endif
-
-ifdef CONFIG_EAP_PAX
-CFLAGS += -DEAP_PAX
-OBJS += ../src/eap_server/eap_pax.o ../src/eap_common/eap_pax_common.o
-endif
-
-ifdef CONFIG_EAP_PSK
-CFLAGS += -DEAP_PSK
-OBJS += ../src/eap_server/eap_psk.o ../src/eap_common/eap_psk_common.o
-endif
-
-ifdef CONFIG_EAP_SAKE
-CFLAGS += -DEAP_SAKE
-OBJS += ../src/eap_server/eap_sake.o ../src/eap_common/eap_sake_common.o
-endif
-
-ifdef CONFIG_EAP_GPSK
-CFLAGS += -DEAP_GPSK
-OBJS += ../src/eap_server/eap_gpsk.o ../src/eap_common/eap_gpsk_common.o
-ifdef CONFIG_EAP_GPSK_SHA256
-CFLAGS += -DEAP_GPSK_SHA256
-endif
-NEED_SHA256=y
-endif
-
-ifdef CONFIG_EAP_VENDOR_TEST
-CFLAGS += -DEAP_VENDOR_TEST
-OBJS += ../src/eap_server/eap_vendor_test.o
-endif
-
-ifdef CONFIG_EAP_FAST
-CFLAGS += -DEAP_FAST
-OBJS += ../src/eap_server/eap_fast.o
-OBJS += ../src/eap_common/eap_fast_common.o
-TLS_FUNCS=y
-NEED_T_PRF=y
-endif
-
-ifdef CONFIG_WPS
-CFLAGS += -DCONFIG_WPS -DEAP_WSC
-OBJS += ../src/utils/uuid.o
-OBJS += wps_hostapd.o
-OBJS += ../src/eap_server/eap_wsc.o ../src/eap_common/eap_wsc_common.o
-OBJS += ../src/wps/wps.o
-OBJS += ../src/wps/wps_common.o
-OBJS += ../src/wps/wps_attr_parse.o
-OBJS += ../src/wps/wps_attr_build.o
-OBJS += ../src/wps/wps_attr_process.o
-OBJS += ../src/wps/wps_dev_attr.o
-OBJS += ../src/wps/wps_enrollee.o
-OBJS += ../src/wps/wps_registrar.o
-NEED_DH_GROUPS=y
-NEED_SHA256=y
-NEED_CRYPTO=y
-NEED_BASE64=y
-
-ifdef CONFIG_WPS_UPNP
-CFLAGS += -DCONFIG_WPS_UPNP
-OBJS += ../src/wps/wps_upnp.o
-OBJS += ../src/wps/wps_upnp_ssdp.o
-OBJS += ../src/wps/wps_upnp_web.o
-OBJS += ../src/wps/wps_upnp_event.o
-OBJS += ../src/wps/httpread.o
-endif
-
-endif
-
-ifdef CONFIG_EAP_IKEV2
-CFLAGS += -DEAP_IKEV2
-OBJS += ../src/eap_server/eap_ikev2.o ../src/eap_server/ikev2.o
-OBJS += ../src/eap_common/eap_ikev2_common.o ../src/eap_common/ikev2_common.o
-NEED_DH_GROUPS=y
-NEED_DH_GROUPS_ALL=y
-endif
-
-ifdef CONFIG_EAP_TNC
-CFLAGS += -DEAP_TNC
-OBJS += ../src/eap_server/eap_tnc.o
-OBJS += ../src/eap_server/tncs.o
-NEED_BASE64=y
-ifndef CONFIG_DRIVER_BSD
-LIBS += -ldl
-endif
-endif
-
-# Basic EAP functionality is needed for EAPOL
-OBJS += ../src/eap_server/eap.o
-OBJS += ../src/eap_common/eap_common.o
-OBJS += ../src/eap_server/eap_methods.o
-OBJS += ../src/eap_server/eap_identity.o
-
-ifdef CONFIG_EAP
-CFLAGS += -DEAP_SERVER
-endif
-
-ifndef CONFIG_TLS
-CONFIG_TLS=openssl
-endif
-
-ifeq ($(CONFIG_TLS), internal)
-ifndef CONFIG_CRYPTO
-CONFIG_CRYPTO=internal
-endif
-endif
-ifeq ($(CONFIG_CRYPTO), libtomcrypt)
-CFLAGS += -DCONFIG_INTERNAL_X509
-endif
-ifeq ($(CONFIG_CRYPTO), internal)
-CFLAGS += -DCONFIG_INTERNAL_X509
-endif
-
-
-ifdef TLS_FUNCS
-# Shared TLS functions (needed for EAP_TLS, EAP_PEAP, and EAP_TTLS)
-CFLAGS += -DEAP_TLS_FUNCS
-OBJS += ../src/eap_server/eap_tls_common.o
-NEED_TLS_PRF=y
-ifeq ($(CONFIG_TLS), openssl)
-OBJS += ../src/crypto/tls_openssl.o
-LIBS += -lssl -lcrypto
-LIBS_p += -lcrypto
-LIBS_h += -lcrypto
-endif
-ifeq ($(CONFIG_TLS), gnutls)
-OBJS += ../src/crypto/tls_gnutls.o
-LIBS += -lgnutls -lgcrypt -lgpg-error
-LIBS_p += -lgcrypt
-LIBS_h += -lgcrypt
-endif
-ifdef CONFIG_GNUTLS_EXTRA
-CFLAGS += -DCONFIG_GNUTLS_EXTRA
-LIBS += -lgnutls-extra
-endif
-ifeq ($(CONFIG_TLS), internal)
-OBJS += ../src/crypto/tls_internal.o
-OBJS += ../src/tls/tlsv1_common.o ../src/tls/tlsv1_record.o
-OBJS += ../src/tls/tlsv1_cred.o ../src/tls/tlsv1_server.o
-OBJS += ../src/tls/tlsv1_server_write.o ../src/tls/tlsv1_server_read.o
-OBJS += ../src/tls/asn1.o ../src/tls/x509v3.o
-OBJS_p += ../src/tls/asn1.o
-OBJS_p += ../src/crypto/rc4.o ../src/crypto/aes_wrap.o ../src/crypto/aes.o
-NEED_BASE64=y
-CFLAGS += -DCONFIG_TLS_INTERNAL
-CFLAGS += -DCONFIG_TLS_INTERNAL_SERVER
-ifeq ($(CONFIG_CRYPTO), internal)
-ifdef CONFIG_INTERNAL_LIBTOMMATH
-CFLAGS += -DCONFIG_INTERNAL_LIBTOMMATH
-else
-LIBS += -ltommath
-LIBS_p += -ltommath
-endif
-endif
-ifeq ($(CONFIG_CRYPTO), libtomcrypt)
-LIBS += -ltomcrypt -ltfm
-LIBS_p += -ltomcrypt -ltfm
-endif
-endif
-NEED_CRYPTO=y
-else
-OBJS += ../src/crypto/tls_none.o
-endif
-
-ifdef CONFIG_PKCS12
-CFLAGS += -DPKCS12_FUNCS
-endif
-
-ifdef MS_FUNCS
-OBJS += ../src/crypto/ms_funcs.o
-NEED_CRYPTO=y
-endif
-
-ifdef CHAP
-OBJS += ../src/eap_common/chap.o
-endif
-
-ifdef NEED_CRYPTO
-ifndef TLS_FUNCS
-ifeq ($(CONFIG_TLS), openssl)
-LIBS += -lcrypto
-LIBS_p += -lcrypto
-LIBS_h += -lcrypto
-endif
-ifeq ($(CONFIG_TLS), gnutls)
-LIBS += -lgcrypt
-LIBS_p += -lgcrypt
-LIBS_h += -lgcrypt
-endif
-ifeq ($(CONFIG_TLS), internal)
-ifeq ($(CONFIG_CRYPTO), libtomcrypt)
-LIBS += -ltomcrypt -ltfm
-LIBS_p += -ltomcrypt -ltfm
-endif
-endif
-endif
-ifeq ($(CONFIG_TLS), openssl)
-OBJS += ../src/crypto/crypto_openssl.o
-OBJS_p += ../src/crypto/crypto_openssl.o
-HOBJS += ../src/crypto/crypto_openssl.o
-CONFIG_INTERNAL_SHA256=y
-endif
-ifeq ($(CONFIG_TLS), gnutls)
-OBJS += ../src/crypto/crypto_gnutls.o
-OBJS_p += ../src/crypto/crypto_gnutls.o
-HOBJS += ../src/crypto/crypto_gnutls.o
-CONFIG_INTERNAL_SHA256=y
-endif
-ifeq ($(CONFIG_TLS), internal)
-ifeq ($(CONFIG_CRYPTO), libtomcrypt)
-OBJS += ../src/crypto/crypto_libtomcrypt.o
-OBJS_p += ../src/crypto/crypto_libtomcrypt.o
-CONFIG_INTERNAL_SHA256=y
-endif
-ifeq ($(CONFIG_CRYPTO), internal)
-OBJS += ../src/crypto/crypto_internal.o ../src/tls/rsa.o ../src/tls/bignum.o
-OBJS_p += ../src/crypto/crypto_internal.o ../src/tls/rsa.o ../src/tls/bignum.o
-CFLAGS += -DCONFIG_CRYPTO_INTERNAL
-ifdef CONFIG_INTERNAL_LIBTOMMATH
-CFLAGS += -DCONFIG_INTERNAL_LIBTOMMATH
-ifdef CONFIG_INTERNAL_LIBTOMMATH_FAST
-CFLAGS += -DLTM_FAST
-endif
-else
-LIBS += -ltommath
-LIBS_p += -ltommath
-endif
-CONFIG_INTERNAL_AES=y
-CONFIG_INTERNAL_DES=y
-CONFIG_INTERNAL_SHA1=y
-CONFIG_INTERNAL_MD4=y
-CONFIG_INTERNAL_MD5=y
-CONFIG_INTERNAL_SHA256=y
-endif
-endif
-else
-CONFIG_INTERNAL_AES=y
-CONFIG_INTERNAL_SHA1=y
-CONFIG_INTERNAL_MD5=y
-CONFIG_INTERNAL_SHA256=y
-endif
-
-ifdef CONFIG_INTERNAL_AES
-CFLAGS += -DINTERNAL_AES
-endif
-ifdef CONFIG_INTERNAL_SHA1
-CFLAGS += -DINTERNAL_SHA1
-endif
-ifdef CONFIG_INTERNAL_SHA256
-CFLAGS += -DINTERNAL_SHA256
-endif
-ifdef CONFIG_INTERNAL_MD5
-CFLAGS += -DINTERNAL_MD5
-endif
-ifdef CONFIG_INTERNAL_MD4
-CFLAGS += -DINTERNAL_MD4
-endif
-ifdef CONFIG_INTERNAL_DES
-CFLAGS += -DINTERNAL_DES
-endif
-
-ifdef NEED_SHA256
-OBJS += ../src/crypto/sha256.o
-endif
-
-ifdef NEED_DH_GROUPS
-OBJS += ../src/crypto/dh_groups.o
-ifdef NEED_DH_GROUPS_ALL
-CFLAGS += -DALL_DH_GROUPS
-endif
-endif
-
-ifndef NEED_FIPS186_2_PRF
-CFLAGS += -DCONFIG_NO_FIPS186_2_PRF
-endif
-
-ifndef NEED_T_PRF
-CFLAGS += -DCONFIG_NO_T_PRF
-endif
-
-ifndef NEED_TLS_PRF
-CFLAGS += -DCONFIG_NO_TLS_PRF
-endif
-
-ifdef CONFIG_RADIUS_SERVER
-CFLAGS += -DRADIUS_SERVER
-OBJS += ../src/radius/radius_server.o
-endif
-
-ifdef CONFIG_IPV6
-CFLAGS += -DCONFIG_IPV6
-endif
-
-ifdef CONFIG_DRIVER_RADIUS_ACL
-CFLAGS += -DCONFIG_DRIVER_RADIUS_ACL
-endif
-
-ifdef CONFIG_FULL_DYNAMIC_VLAN
-# define CONFIG_FULL_DYNAMIC_VLAN to have hostapd manipulate bridges
-# and vlan interfaces for the vlan feature.
-CFLAGS += -DCONFIG_FULL_DYNAMIC_VLAN
-endif
-
-ifdef NEED_BASE64
-OBJS += ../src/utils/base64.o
-endif
-
-ifdef CONFIG_NO_STDOUT_DEBUG
-CFLAGS += -DCONFIG_NO_STDOUT_DEBUG
-endif
-
-ifdef CONFIG_NO_AES_EXTRAS
-CFLAGS += -DCONFIG_NO_AES_UNWRAP
-CFLAGS += -DCONFIG_NO_AES_CTR -DCONFIG_NO_AES_OMAC1
-CFLAGS += -DCONFIG_NO_AES_EAX -DCONFIG_NO_AES_CBC
-CFLAGS += -DCONFIG_NO_AES_DECRYPT
-CFLAGS += -DCONFIG_NO_AES_ENCRYPT_BLOCK
-endif
-
-ALL=hostapd hostapd_cli
-
-all: verify_config $(ALL)
-
-Q=@
-E=echo
-ifeq ($(V), 1)
-Q=
-E=true
-endif
-
-%.o: %.c
- $(Q)$(CC) -c -o $@ $(CFLAGS) $<
- @$(E) " CC " $<
-
-verify_config:
- @if [ ! -r .config ]; then \
- echo 'Building hostapd requires a configuration file'; \
- echo '(.config). See README for more instructions. You can'; \
- echo 'run "cp defconfig .config" to create an example'; \
- echo 'configuration.'; \
- exit 1; \
- fi
-
-install: all
- for i in $(ALL); do cp $$i /usr/local/bin/$$i; done
-
-hostapd: $(OBJS)
- $(CC) -o hostapd $(OBJS) $(LIBS)
-
-OBJS_c = hostapd_cli.o ../src/common/wpa_ctrl.o ../src/utils/os_$(CONFIG_OS).o
-hostapd_cli: $(OBJS_c)
- $(CC) -o hostapd_cli $(OBJS_c)
-
-NOBJS = nt_password_hash.o ../src/crypto/ms_funcs.o ../src/crypto/sha1.o ../src/crypto/rc4.o ../src/crypto/md5.o
-NOBJS += ../src/crypto/crypto_openssl.o ../src/utils/os_$(CONFIG_OS).o
-ifdef TLS_FUNCS
-LIBS_n += -lcrypto
-endif
-
-nt_password_hash: $(NOBJS)
- $(CC) -o nt_password_hash $(NOBJS) $(LIBS_n)
-
-hlr_auc_gw: $(HOBJS)
- $(CC) -o hlr_auc_gw $(HOBJS) $(LIBS_h)
-
-clean:
- $(MAKE) -C ../src clean
- rm -f core *~ *.o hostapd hostapd_cli nt_password_hash hlr_auc_gw
- rm -f *.d
-
-%.eps: %.fig
- fig2dev -L eps $*.fig $*.eps
-
-%.png: %.fig
- fig2dev -L png -m 3 $*.fig | pngtopnm | pnmscale 0.4 | pnmtopng \
- > $*.png
-
-docs-pics: doc/hostapd.png doc/hostapd.eps
-
-docs: docs-pics
- (cd ..; doxygen hostapd/doc/doxygen.full; cd hostapd)
- $(MAKE) -C doc/latex
- cp doc/latex/refman.pdf hostapd-devel.pdf
-
-docs-fast: docs-pics
- (cd ..; doxygen hostapd/doc/doxygen.fast; cd hostapd)
-
-clean-docs:
- rm -rf doc/latex doc/html
- rm -f doc/hostapd.{eps,png} hostapd-devel.pdf
-
-TEST_SRC_MILENAGE = ../src/hlr_auc_gw/milenage.c ../src/crypto/aes_wrap.c ../src/crypto/aes.c ../src/utils/common.c ../src/utils/wpa_debug.o ../src/utils/os_$(CONFIG_OS).c
-test-milenage: $(TEST_SRC_MILENAGE)
- $(CC) -o test-milenage -Wall -Werror $(TEST_SRC_MILENAGE) \
- -DTEST_MAIN_MILENAGE -I. -DINTERNAL_AES \
- -I../src/crypto -I../src/utils
- ./test-milenage
- rm test-milenage
-
--include $(OBJS:%.o=%.d)
diff --git a/hostapd/README b/hostapd/README
deleted file mode 100644
index eb9aa4815b4f..000000000000
--- a/hostapd/README
+++ /dev/null
@@ -1,390 +0,0 @@
-hostapd - user space IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP
- Authenticator and RADIUS authentication server
-================================================================
-
-Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi> and contributors
-All Rights Reserved.
-
-This program is dual-licensed under both the GPL version 2 and BSD
-license. Either license may be used at your option.
-
-
-
-License
--------
-
-GPL v2:
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License version 2 as
-published by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-(this copy of the license is in COPYING file)
-
-
-Alternatively, this software may be distributed, used, and modified
-under the terms of BSD license:
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
-3. Neither the name(s) of the above-listed copyright holder(s) nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-
-Introduction
-============
-
-Originally, hostapd was an optional user space component for Host AP
-driver. It adds more features to the basic IEEE 802.11 management
-included in the kernel driver: using external RADIUS authentication
-server for MAC address based access control, IEEE 802.1X Authenticator
-and dynamic WEP keying, RADIUS accounting, WPA/WPA2 (IEEE 802.11i/RSN)
-Authenticator and dynamic TKIP/CCMP keying.
-
-The current version includes support for other drivers, an integrated
-EAP server (i.e., allow full authentication without requiring
-an external RADIUS authentication server), and RADIUS authentication
-server for EAP authentication.
-
-
-Requirements
-------------
-
-Current hardware/software requirements:
-- drivers:
- Host AP driver for Prism2/2.5/3.
- (http://hostap.epitest.fi/)
- Please note that station firmware version needs to be 1.7.0 or newer
- to work in WPA mode.
-
- madwifi driver for cards based on Atheros chip set (ar521x)
- (http://sourceforge.net/projects/madwifi/)
- Please note that you will need to add the correct path for
- madwifi driver root directory in .config (see defconfig file for
- an example: CFLAGS += -I<path>)
-
- Prism54 driver for Intersil/Conexant Prism GT/Duette/Indigo
- (http://www.prism54.org/)
-
- mac80211-based drivers that support AP mode (with driver=nl80211).
- This includes drivers for Atheros (ath9k) and Broadcom (b43)
- chipsets.
-
- Any wired Ethernet driver for wired IEEE 802.1X authentication
- (experimental code)
-
- FreeBSD -current (with some kernel mods that have not yet been
- committed when hostapd v0.3.0 was released)
- BSD net80211 layer (e.g., Atheros driver)
-
-
-Build configuration
--------------------
-
-In order to be able to build hostapd, you will need to create a build
-time configuration file, .config that selects which optional
-components are included. See defconfig file for example configuration
-and list of available options.
-
-
-
-IEEE 802.1X
-===========
-
-IEEE Std 802.1X-2001 is a standard for port-based network access
-control. In case of IEEE 802.11 networks, a "virtual port" is used
-between each associated station and the AP. IEEE 802.11 specifies
-minimal authentication mechanism for stations, whereas IEEE 802.1X
-introduces a extensible mechanism for authenticating and authorizing
-users.
-
-IEEE 802.1X uses elements called Supplicant, Authenticator, Port
-Access Entity, and Authentication Server. Supplicant is a component in
-a station and it performs the authentication with the Authentication
-Server. An access point includes an Authenticator that relays the packets
-between a Supplicant and an Authentication Server. In addition, it has a
-Port Access Entity (PAE) with Authenticator functionality for
-controlling the virtual port authorization, i.e., whether to accept
-packets from or to the station.
-
-IEEE 802.1X uses Extensible Authentication Protocol (EAP). The frames
-between a Supplicant and an Authenticator are sent using EAP over LAN
-(EAPOL) and the Authenticator relays these frames to the Authentication
-Server (and similarly, relays the messages from the Authentication
-Server to the Supplicant). The Authentication Server can be colocated with the
-Authenticator, in which case there is no need for additional protocol
-for EAP frame transmission. However, a more common configuration is to
-use an external Authentication Server and encapsulate EAP frame in the
-frames used by that server. RADIUS is suitable for this, but IEEE
-802.1X would also allow other mechanisms.
-
-Host AP driver includes PAE functionality in the kernel driver. It
-is a relatively simple mechanism for denying normal frames going to
-or coming from an unauthorized port. PAE allows IEEE 802.1X related
-frames to be passed between the Supplicant and the Authenticator even
-on an unauthorized port.
-
-User space daemon, hostapd, includes Authenticator functionality. It
-receives 802.1X (EAPOL) frames from the Supplicant using the wlan#ap
-device that is also used with IEEE 802.11 management frames. The
-frames to the Supplicant are sent using the same device.
-
-The normal configuration of the Authenticator would use an external
-Authentication Server. hostapd supports RADIUS encapsulation of EAP
-packets, so the Authentication Server should be a RADIUS server, like
-FreeRADIUS (http://www.freeradius.org/). The Authenticator in hostapd
-relays the frames between the Supplicant and the Authentication
-Server. It also controls the PAE functionality in the kernel driver by
-controlling virtual port authorization, i.e., station-AP
-connection, based on the IEEE 802.1X state.
-
-When a station would like to use the services of an access point, it
-will first perform IEEE 802.11 authentication. This is normally done
-with open systems authentication, so there is no security. After
-this, IEEE 802.11 association is performed. If IEEE 802.1X is
-configured to be used, the virtual port for the station is set in
-Unauthorized state and only IEEE 802.1X frames are accepted at this
-point. The Authenticator will then ask the Supplicant to authenticate
-with the Authentication Server. After this is completed successfully,
-the virtual port is set to Authorized state and frames from and to the
-station are accepted.
-
-Host AP configuration for IEEE 802.1X
--------------------------------------
-
-The user space daemon has its own configuration file that can be used to
-define AP options. Distribution package contains an example
-configuration file (hostapd/hostapd.conf) that can be used as a basis
-for configuration. It includes examples of all supported configuration
-options and short description of each option. hostapd should be started
-with full path to the configuration file as the command line argument,
-e.g., './hostapd /etc/hostapd.conf'. If you have more that one wireless
-LAN card, you can use one hostapd process for multiple interfaces by
-giving a list of configuration files (one per interface) in the command
-line.
-
-hostapd includes a minimal co-located IEEE 802.1X server which can be
-used to test IEEE 802.1X authentication. However, it should not be
-used in normal use since it does not provide any security. This can be
-configured by setting ieee8021x and minimal_eap options in the
-configuration file.
-
-An external Authentication Server (RADIUS) is configured with
-auth_server_{addr,port,shared_secret} options. In addition,
-ieee8021x and own_ip_addr must be set for this mode. With such
-configuration, the co-located Authentication Server is not used and EAP
-frames will be relayed using EAPOL between the Supplicant and the
-Authenticator and RADIUS encapsulation between the Authenticator and
-the Authentication Server. Other than this, the functionality is similar
-to the case with the co-located Authentication Server.
-
-Authentication Server and Supplicant
-------------------------------------
-
-Any RADIUS server supporting EAP should be usable as an IEEE 802.1X
-Authentication Server with hostapd Authenticator. FreeRADIUS
-(http://www.freeradius.org/) has been successfully tested with hostapd
-Authenticator and both Xsupplicant (http://www.open1x.org) and Windows
-XP Supplicants. EAP/TLS was used with Xsupplicant and
-EAP/MD5-Challenge with Windows XP.
-
-http://www.missl.cs.umd.edu/wireless/eaptls/ has useful information
-about using EAP/TLS with FreeRADIUS and Xsupplicant (just replace
-Cisco access point with Host AP driver, hostapd daemon, and a Prism2
-card ;-). http://www.freeradius.org/doc/EAP-MD5.html has information
-about using EAP/MD5 with FreeRADIUS, including instructions for WinXP
-configuration. http://www.denobula.com/EAPTLS.pdf has a HOWTO on
-EAP/TLS use with WinXP Supplicant.
-
-Automatic WEP key configuration
--------------------------------
-
-EAP/TLS generates a session key that can be used to send WEP keys from
-an AP to authenticated stations. The Authenticator in hostapd can be
-configured to automatically select a random default/broadcast key
-(shared by all authenticated stations) with wep_key_len_broadcast
-option (5 for 40-bit WEP or 13 for 104-bit WEP). In addition,
-wep_key_len_unicast option can be used to configure individual unicast
-keys for stations. This requires support for individual keys in the
-station driver.
-
-WEP keys can be automatically updated by configuring rekeying. This
-will improve security of the network since same WEP key will only be
-used for a limited period of time. wep_rekey_period option sets the
-interval for rekeying in seconds.
-
-
-WPA/WPA2
-========
-
-Features
---------
-
-Supported WPA/IEEE 802.11i features:
-- WPA-PSK ("WPA-Personal")
-- WPA with EAP (e.g., with RADIUS authentication server) ("WPA-Enterprise")
-- key management for CCMP, TKIP, WEP104, WEP40
-- RSN/WPA2 (IEEE 802.11i), including PMKSA caching and pre-authentication
-
-WPA
----
-
-The original security mechanism of IEEE 802.11 standard was not
-designed to be strong and has proved to be insufficient for most
-networks that require some kind of security. Task group I (Security)
-of IEEE 802.11 working group (http://www.ieee802.org/11/) has worked
-to address the flaws of the base standard and has in practice
-completed its work in May 2004. The IEEE 802.11i amendment to the IEEE
-802.11 standard was approved in June 2004 and this amendment is likely
-to be published in July 2004.
-
-Wi-Fi Alliance (http://www.wi-fi.org/) used a draft version of the
-IEEE 802.11i work (draft 3.0) to define a subset of the security
-enhancements that can be implemented with existing wlan hardware. This
-is called Wi-Fi Protected Access<TM> (WPA). This has now become a
-mandatory component of interoperability testing and certification done
-by Wi-Fi Alliance. Wi-Fi provides information about WPA at its web
-site (http://www.wi-fi.org/OpenSection/protected_access.asp).
-
-IEEE 802.11 standard defined wired equivalent privacy (WEP) algorithm
-for protecting wireless networks. WEP uses RC4 with 40-bit keys,
-24-bit initialization vector (IV), and CRC32 to protect against packet
-forgery. All these choices have proven to be insufficient: key space is
-too small against current attacks, RC4 key scheduling is insufficient
-(beginning of the pseudorandom stream should be skipped), IV space is
-too small and IV reuse makes attacks easier, there is no replay
-protection, and non-keyed authentication does not protect against bit
-flipping packet data.
-
-WPA is an intermediate solution for the security issues. It uses
-Temporal Key Integrity Protocol (TKIP) to replace WEP. TKIP is a
-compromise on strong security and possibility to use existing
-hardware. It still uses RC4 for the encryption like WEP, but with
-per-packet RC4 keys. In addition, it implements replay protection,
-keyed packet authentication mechanism (Michael MIC).
-
-Keys can be managed using two different mechanisms. WPA can either use
-an external authentication server (e.g., RADIUS) and EAP just like
-IEEE 802.1X is using or pre-shared keys without need for additional
-servers. Wi-Fi calls these "WPA-Enterprise" and "WPA-Personal",
-respectively. Both mechanisms will generate a master session key for
-the Authenticator (AP) and Supplicant (client station).
-
-WPA implements a new key handshake (4-Way Handshake and Group Key
-Handshake) for generating and exchanging data encryption keys between
-the Authenticator and Supplicant. This handshake is also used to
-verify that both Authenticator and Supplicant know the master session
-key. These handshakes are identical regardless of the selected key
-management mechanism (only the method for generating master session
-key changes).
-
-
-IEEE 802.11i / WPA2
--------------------
-
-The design for parts of IEEE 802.11i that were not included in WPA has
-finished (May 2004) and this amendment to IEEE 802.11 was approved in
-June 2004. Wi-Fi Alliance is using the final IEEE 802.11i as a new
-version of WPA called WPA2. This includes, e.g., support for more
-robust encryption algorithm (CCMP: AES in Counter mode with CBC-MAC)
-to replace TKIP and optimizations for handoff (reduced number of
-messages in initial key handshake, pre-authentication, and PMKSA caching).
-
-Some wireless LAN vendors are already providing support for CCMP in
-their WPA products. There is no "official" interoperability
-certification for CCMP and/or mixed modes using both TKIP and CCMP, so
-some interoperability issues can be expected even though many
-combinations seem to be working with equipment from different vendors.
-Testing for WPA2 is likely to start during the second half of 2004.
-
-hostapd configuration for WPA/WPA2
-----------------------------------
-
-TODO
-
-# Enable WPA. Setting this variable configures the AP to require WPA (either
-# WPA-PSK or WPA-RADIUS/EAP based on other configuration). For WPA-PSK, either
-# wpa_psk or wpa_passphrase must be set and wpa_key_mgmt must include WPA-PSK.
-# For WPA-RADIUS/EAP, ieee8021x must be set (but without dynamic WEP keys),
-# RADIUS authentication server must be configured, and WPA-EAP must be included
-# in wpa_key_mgmt.
-# This field is a bit field that can be used to enable WPA (IEEE 802.11i/D3.0)
-# and/or WPA2 (full IEEE 802.11i/RSN):
-# bit0 = WPA
-# bit1 = IEEE 802.11i/RSN (WPA2)
-#wpa=1
-
-# WPA pre-shared keys for WPA-PSK. This can be either entered as a 256-bit
-# secret in hex format (64 hex digits), wpa_psk, or as an ASCII passphrase
-# (8..63 characters) that will be converted to PSK. This conversion uses SSID
-# so the PSK changes when ASCII passphrase is used and the SSID is changed.
-#wpa_psk=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
-#wpa_passphrase=secret passphrase
-
-# Set of accepted key management algorithms (WPA-PSK, WPA-EAP, or both). The
-# entries are separated with a space.
-#wpa_key_mgmt=WPA-PSK WPA-EAP
-
-# Set of accepted cipher suites (encryption algorithms) for pairwise keys
-# (unicast packets). This is a space separated list of algorithms:
-# CCMP = AES in Counter mode with CBC-MAC [RFC 3610, IEEE 802.11i]
-# TKIP = Temporal Key Integrity Protocol [IEEE 802.11i]
-# Group cipher suite (encryption algorithm for broadcast and multicast frames)
-# is automatically selected based on this configuration. If only CCMP is
-# allowed as the pairwise cipher, group cipher will also be CCMP. Otherwise,
-# TKIP will be used as the group cipher.
-#wpa_pairwise=TKIP CCMP
-
-# Time interval for rekeying GTK (broadcast/multicast encryption keys) in
-# seconds.
-#wpa_group_rekey=600
-
-# Time interval for rekeying GMK (master key used internally to generate GTKs
-# (in seconds).
-#wpa_gmk_rekey=86400
-
-# Enable IEEE 802.11i/RSN/WPA2 pre-authentication. This is used to speed up
-# roaming be pre-authenticating IEEE 802.1X/EAP part of the full RSN
-# authentication and key handshake before actually associating with a new AP.
-#rsn_preauth=1
-#
-# Space separated list of interfaces from which pre-authentication frames are
-# accepted (e.g., 'eth0' or 'eth0 wlan0wds0'. This list should include all
-# interface that are used for connections to other APs. This could include
-# wired interfaces and WDS links. The normal wireless data interface towards
-# associated stations (e.g., wlan0) should not be added, since
-# pre-authentication is only used with APs other than the currently associated
-# one.
-#rsn_preauth_interfaces=eth0
diff --git a/hostapd/README-WPS b/hostapd/README-WPS
deleted file mode 100644
index e0e370b5bc8f..000000000000
--- a/hostapd/README-WPS
+++ /dev/null
@@ -1,239 +0,0 @@
-hostapd and Wi-Fi Protected Setup (WPS)
-=======================================
-
-This document describes how the WPS implementation in hostapd can be
-configured and how an external component on an AP (e.g., web UI) is
-used to enable enrollment of client devices.
-
-
-Introduction to WPS
--------------------
-
-Wi-Fi Protected Setup (WPS) is a mechanism for easy configuration of a
-wireless network. It allows automated generation of random keys (WPA
-passphrase/PSK) and configuration of an access point and client
-devices. WPS includes number of methods for setting up connections
-with PIN method and push-button configuration (PBC) being the most
-commonly deployed options.
-
-While WPS can enable more home networks to use encryption in the
-wireless network, it should be noted that the use of the PIN and
-especially PBC mechanisms for authenticating the initial key setup is
-not very secure. As such, use of WPS may not be suitable for
-environments that require secure network access without chance for
-allowing outsiders to gain access during the setup phase.
-
-WPS uses following terms to describe the entities participating in the
-network setup:
-- access point: the WLAN access point
-- Registrar: a device that control a network and can authorize
- addition of new devices); this may be either in the AP ("internal
- Registrar") or in an external device, e.g., a laptop, ("external
- Registrar")
-- Enrollee: a device that is being authorized to use the network
-
-It should also be noted that the AP and a client device may change
-roles (i.e., AP acts as an Enrollee and client device as a Registrar)
-when WPS is used to configure the access point.
-
-
-More information about WPS is available from Wi-Fi Alliance:
-http://www.wi-fi.org/wifi-protected-setup
-
-
-hostapd implementation
-----------------------
-
-hostapd includes an optional WPS component that can be used as an
-internal WPS Registrar to manage addition of new WPS enabled clients
-to the network. In addition, WPS Enrollee functionality in hostapd can
-be used to allow external WPS Registrars to configure the access
-point, e.g., for initial network setup. In addition, hostapd can proxy a
-WPS registration between a wireless Enrollee and an external Registrar
-(e.g., Microsoft Vista or Atheros JumpStart) with UPnP.
-
-
-hostapd configuration
----------------------
-
-WPS is an optional component that needs to be enabled in hostapd build
-configuration (.config). Here is an example configuration that
-includes WPS support and uses madwifi driver interface:
-
-CONFIG_DRIVER_MADWIFI=y
-CFLAGS += -I/usr/src/madwifi-0.9.3
-CONFIG_EAP=y
-CONFIG_WPS=y
-CONFIG_WPS_UPNP=y
-
-
-Following section shows an example runtime configuration
-(hostapd.conf) that enables WPS:
-
-# Configure the driver and network interface
-driver=madwifi
-interface=ath0
-
-# WPA2-Personal configuration for the AP
-ssid=wps-test
-wpa=2
-wpa_key_mgmt=WPA-PSK
-wpa_pairwise=CCMP
-# Default WPA passphrase for legacy (non-WPS) clients
-wpa_passphrase=12345678
-# Enable random per-device PSK generation for WPS clients
-# Please note that the file has to exists for hostapd to start (i.e., create an
-# empty file as a starting point).
-wpa_psk_file=/etc/hostapd.psk
-
-# Enable control interface for PBC/PIN entry
-ctrl_interface=/var/run/hostapd
-
-# Enable internal EAP server for EAP-WSC (part of Wi-Fi Protected Setup)
-eap_server=1
-
-# WPS configuration (AP configured, do not allow external WPS Registrars)
-wps_state=2
-ap_setup_locked=1
-# If UUID is not configured, it will be generated based on local MAC address.
-uuid=87654321-9abc-def0-1234-56789abc0000
-wps_pin_requests=/var/run/hostapd.pin-req
-device_name=Wireless AP
-manufacturer=Company
-model_name=WAP
-model_number=123
-serial_number=12345
-device_type=6-0050F204-1
-os_version=01020300
-config_methods=label display push_button keypad
-
-# if external Registrars are allowed, UPnP support could be added:
-#upnp_iface=br0
-#friendly_name=WPS Access Point
-
-
-External operations
--------------------
-
-WPS requires either a device PIN code (usually, 8-digit number) or a
-pushbutton event (for PBC) to allow a new WPS Enrollee to join the
-network. hostapd uses the control interface as an input channel for
-these events.
-
-When a client device (WPS Enrollee) connects to hostapd (WPS
-Registrar) in order to start PIN mode negotiation for WPS, an
-identifier (Enrollee UUID) is sent. hostapd will need to be configured
-with a device password (PIN) for this Enrollee. This is an operation
-that requires user interaction (assuming there are no pre-configured
-PINs on the AP for a set of Enrollee).
-
-The PIN request with information about the device is appended to the
-wps_pin_requests file (/var/run/hostapd.pin-req in this example). In
-addition, hostapd control interface event is sent as a notification of
-a new device. The AP could use, e.g., a web UI for showing active
-Enrollees to the user and request a PIN for an Enrollee.
-
-The PIN request file has one line for every Enrollee that connected to
-the AP, but for which there was no PIN. Following information is
-provided for each Enrollee (separated with tabulators):
-- timestamp (seconds from 1970-01-01)
-- Enrollee UUID
-- MAC address
-- Device name
-- Manufacturer
-- Model Name
-- Model Number
-- Serial Number
-- Device category
-
-Example line in the /var/run/hostapd.pin-req file:
-1200188391 53b63a98-d29e-4457-a2ed-094d7e6a669c Intel(R) Centrino(R) Intel Corporation Intel(R) Centrino(R) - - 1-0050F204-1
-
-Control interface data:
-WPS-PIN-NEEDED [UUID-E|MAC Address|Device Name|Manufacturer|Model Name|Model Number|Serial Number|Device Category]
-For example:
-<2>WPS-PIN-NEEDED [53b63a98-d29e-4457-a2ed-094d7e6a669c|02:12:34:56:78:9a|Device|Manuf|Model|Model Number|Serial Number|1-0050F204-1]
-
-When the user enters a PIN for a pending Enrollee, e.g., on the web
-UI), hostapd needs to be notified of the new PIN over the control
-interface. This can be done either by using the UNIX domain socket
--based control interface directly (src/common/wpa_ctrl.c provides
-helper functions for using the interface) or by calling hostapd_cli.
-
-Example command to add a PIN (12345670) for an Enrollee:
-
-hostapd_cli wps_pin 53b63a98-d29e-4457-a2ed-094d7e6a669c 12345670
-
-If the UUID-E is not available (e.g., Enrollee waits for the Registrar
-to be selected before connecting), wildcard UUID may be used to allow
-the PIN to be used once with any UUID:
-
-hostapd_cli wps_pin any 12345670
-
-To reduce likelihood of PIN being used with other devices or of
-forgetting an active PIN available for potential attackers, expiration
-time can be set for the new PIN:
-
-hostapd_cli wps_pin any 12345670 300
-
-
-After this, the Enrollee can connect to the AP again and complete WPS
-negotiation. At that point, a new, random WPA PSK is generated for the
-client device and the client can then use that key to connect to the
-AP to access the network.
-
-
-If the AP includes a pushbutton, WPS PBC mode can be used. It is
-enabled by pushing a button on both the AP and the client at about the
-same time (2 minute window). hostapd needs to be notified about the AP
-button pushed event over the control interface, e.g., by calling
-hostapd_cli:
-
-hostapd_cli wps_pbc
-
-At this point, the client has two minutes to complete WPS negotiation
-which will generate a new WPA PSK in the same way as the PIN method
-described above.
-
-
-Credential generation and configuration changes
------------------------------------------------
-
-By default, hostapd generates credentials for Enrollees and processing
-AP configuration updates internally. However, it is possible to
-control these operations from external programs, if desired.
-
-The internal credential generation can be disabled with
-skip_cred_build=1 option in the configuration. extra_cred option will
-then need to be used to provide pre-configured Credential attribute(s)
-for hostapd to use. The exact data from this binary file will be sent,
-i.e., it will have to include valid WPS attributes. extra_cred can
-also be used to add additional networks if the Registrar is used to
-configure credentials for multiple networks.
-
-Processing of received configuration updates can be disabled with
-wps_cred_processing=1 option. When this is used, an external program
-is responsible for creating hostapd configuration files and processing
-configuration updates based on messages received from hostapd over
-control interface. This will also include the initial configuration on
-first successful registration if the AP is initially set in
-unconfigured state.
-
-Following control interface messages are sent out for external programs:
-
-WPS-REG-SUCCESS <Enrollee MAC address <UUID-E>
-For example:
-<2>WPS-REG-SUCCESS 02:66:a0:ee:17:27 2b7093f1-d6fb-5108-adbb-bea66bb87333
-
-This can be used to tricker change from unconfigured to configured
-state (random configuration based on the first successful WPS
-registration). In addition, this can be used to update AP UI about the
-status of WPS registration progress.
-
-
-WPS-NEW-AP-SETTINGS <hexdump of AP Setup attributes>
-For example:
-<2>WPS-NEW-AP-SETTINGS 10260001011045000c6a6b6d2d7770732d74657374100300020020100f00020008102700403065346230343536633236366665306433396164313535346131663462663731323433376163666462376633393965353466316631623032306164343438623510200006024231cede15101e000844
-
-This can be used to update the externally stored AP configuration and
-then update hostapd configuration (followed by restarting of hostapd).
diff --git a/hostapd/config.c b/hostapd/config.c
deleted file mode 100644
index 692b1a412e02..000000000000
--- a/hostapd/config.c
+++ /dev/null
@@ -1,2622 +0,0 @@
-/*
- * hostapd / Configuration file
- * Copyright (c) 2003-2008, Jouni Malinen <j@w1.fi>
- * Copyright (c) 2007-2008, Intel Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Alternatively, this software may be distributed under the terms of BSD
- * license.
- *
- * See README and COPYING for more details.
- */
-
-#include "includes.h"
-#ifndef CONFIG_NATIVE_WINDOWS
-#include <grp.h>
-#endif /* CONFIG_NATIVE_WINDOWS */
-
-#include "hostapd.h"
-#include "driver.h"
-#include "sha1.h"
-#include "eap_server/eap.h"
-#include "radius/radius_client.h"
-#include "wpa_common.h"
-#include "wpa.h"
-#include "uuid.h"
-#include "eap_common/eap_wsc_common.h"
-
-
-#define MAX_STA_COUNT 2007
-
-extern struct wpa_driver_ops *hostapd_drivers[];
-
-
-static int hostapd_config_read_vlan_file(struct hostapd_bss_config *bss,
- const char *fname)
-{
- FILE *f;
- char buf[128], *pos, *pos2;
- int line = 0, vlan_id;
- struct hostapd_vlan *vlan;
-
- f = fopen(fname, "r");
- if (!f) {
- wpa_printf(MSG_ERROR, "VLAN file '%s' not readable.", fname);
- return -1;
- }
-
- while (fgets(buf, sizeof(buf), f)) {
- line++;
-
- if (buf[0] == '#')
- continue;
- pos = buf;
- while (*pos != '\0') {
- if (*pos == '\n') {
- *pos = '\0';
- break;
- }
- pos++;
- }
- if (buf[0] == '\0')
- continue;
-
- if (buf[0] == '*') {
- vlan_id = VLAN_ID_WILDCARD;
- pos = buf + 1;
- } else {
- vlan_id = strtol(buf, &pos, 10);
- if (buf == pos || vlan_id < 1 ||
- vlan_id > MAX_VLAN_ID) {
- wpa_printf(MSG_ERROR, "Invalid VLAN ID at "
- "line %d in '%s'", line, fname);
- fclose(f);
- return -1;
- }
- }
-
- while (*pos == ' ' || *pos == '\t')
- pos++;
- pos2 = pos;
- while (*pos2 != ' ' && *pos2 != '\t' && *pos2 != '\0')
- pos2++;
- *pos2 = '\0';
- if (*pos == '\0' || os_strlen(pos) > IFNAMSIZ) {
- wpa_printf(MSG_ERROR, "Invalid VLAN ifname at line %d "
- "in '%s'", line, fname);
- fclose(f);
- return -1;
- }
-
- vlan = os_malloc(sizeof(*vlan));
- if (vlan == NULL) {
- wpa_printf(MSG_ERROR, "Out of memory while reading "
- "VLAN interfaces from '%s'", fname);
- fclose(f);
- return -1;
- }
-
- os_memset(vlan, 0, sizeof(*vlan));
- vlan->vlan_id = vlan_id;
- os_strlcpy(vlan->ifname, pos, sizeof(vlan->ifname));
- if (bss->vlan_tail)
- bss->vlan_tail->next = vlan;
- else
- bss->vlan = vlan;
- bss->vlan_tail = vlan;
- }
-
- fclose(f);
-
- return 0;
-}
-
-
-static void hostapd_config_free_vlan(struct hostapd_bss_config *bss)
-{
- struct hostapd_vlan *vlan, *prev;
-
- vlan = bss->vlan;
- prev = NULL;
- while (vlan) {
- prev = vlan;
- vlan = vlan->next;
- os_free(prev);
- }
-
- bss->vlan = NULL;
-}
-
-
-/* convert floats with one decimal place to value*10 int, i.e.,
- * "1.5" will return 15 */
-static int hostapd_config_read_int10(const char *value)
-{
- int i, d;
- char *pos;
-
- i = atoi(value);
- pos = os_strchr(value, '.');
- d = 0;
- if (pos) {
- pos++;
- if (*pos >= '0' && *pos <= '9')
- d = *pos - '0';
- }
-
- return i * 10 + d;
-}
-
-
-static void hostapd_config_defaults_bss(struct hostapd_bss_config *bss)
-{
- bss->logger_syslog_level = HOSTAPD_LEVEL_INFO;
- bss->logger_stdout_level = HOSTAPD_LEVEL_INFO;
- bss->logger_syslog = (unsigned int) -1;
- bss->logger_stdout = (unsigned int) -1;
-
- bss->auth_algs = WPA_AUTH_ALG_OPEN | WPA_AUTH_ALG_SHARED;
-
- bss->wep_rekeying_period = 300;
- /* use key0 in individual key and key1 in broadcast key */
- bss->broadcast_key_idx_min = 1;
- bss->broadcast_key_idx_max = 2;
- bss->eap_reauth_period = 3600;
-
- bss->wpa_group_rekey = 600;
- bss->wpa_gmk_rekey = 86400;
- bss->wpa_key_mgmt = WPA_KEY_MGMT_PSK;
- bss->wpa_pairwise = WPA_CIPHER_TKIP;
- bss->wpa_group = WPA_CIPHER_TKIP;
- bss->rsn_pairwise = 0;
-
- bss->max_num_sta = MAX_STA_COUNT;
-
- bss->dtim_period = 2;
-
- bss->radius_server_auth_port = 1812;
- bss->ap_max_inactivity = AP_MAX_INACTIVITY;
- bss->eapol_version = EAPOL_VERSION;
-
- bss->max_listen_interval = 65535;
-
-#ifdef CONFIG_IEEE80211W
- bss->assoc_sa_query_max_timeout = 1000;
- bss->assoc_sa_query_retry_timeout = 201;
-#endif /* CONFIG_IEEE80211W */
-#ifdef EAP_FAST
- /* both anonymous and authenticated provisioning */
- bss->eap_fast_prov = 3;
- bss->pac_key_lifetime = 7 * 24 * 60 * 60;
- bss->pac_key_refresh_time = 1 * 24 * 60 * 60;
-#endif /* EAP_FAST */
-}
-
-
-static struct hostapd_config * hostapd_config_defaults(void)
-{
- struct hostapd_config *conf;
- struct hostapd_bss_config *bss;
- int i;
- const int aCWmin = 4, aCWmax = 10;
- const struct hostapd_wmm_ac_params ac_bk =
- { aCWmin, aCWmax, 7, 0, 0 }; /* background traffic */
- const struct hostapd_wmm_ac_params ac_be =
- { aCWmin, aCWmax, 3, 0, 0 }; /* best effort traffic */
- const struct hostapd_wmm_ac_params ac_vi = /* video traffic */
- { aCWmin - 1, aCWmin, 2, 3000 / 32, 1 };
- const struct hostapd_wmm_ac_params ac_vo = /* voice traffic */
- { aCWmin - 2, aCWmin - 1, 2, 1500 / 32, 1 };
-
- conf = os_zalloc(sizeof(*conf));
- bss = os_zalloc(sizeof(*bss));
- if (conf == NULL || bss == NULL) {
- wpa_printf(MSG_ERROR, "Failed to allocate memory for "
- "configuration data.");
- os_free(conf);
- os_free(bss);
- return NULL;
- }
-
- /* set default driver based on configuration */
- conf->driver = hostapd_drivers[0];
- if (conf->driver == NULL) {
- wpa_printf(MSG_ERROR, "No driver wrappers registered!");
- os_free(conf);
- os_free(bss);
- return NULL;
- }
-
- bss->radius = os_zalloc(sizeof(*bss->radius));
- if (bss->radius == NULL) {
- os_free(conf);
- os_free(bss);
- return NULL;
- }
-
- hostapd_config_defaults_bss(bss);
-
- conf->num_bss = 1;
- conf->bss = bss;
-
- conf->beacon_int = 100;
- conf->rts_threshold = -1; /* use driver default: 2347 */
- conf->fragm_threshold = -1; /* user driver default: 2346 */
- conf->send_probe_response = 1;
- conf->bridge_packets = INTERNAL_BRIDGE_DO_NOT_CONTROL;
-
- for (i = 0; i < NUM_TX_QUEUES; i++)
- conf->tx_queue[i].aifs = -1; /* use hw default */
-
- conf->wmm_ac_params[0] = ac_be;
- conf->wmm_ac_params[1] = ac_bk;
- conf->wmm_ac_params[2] = ac_vi;
- conf->wmm_ac_params[3] = ac_vo;
-
-#ifdef CONFIG_IEEE80211N
- conf->ht_capab = HT_CAP_INFO_SMPS_DISABLED;
-#endif /* CONFIG_IEEE80211N */
-
- return conf;
-}
-
-
-int hostapd_mac_comp(const void *a, const void *b)
-{
- return os_memcmp(a, b, sizeof(macaddr));
-}
-
-
-int hostapd_mac_comp_empty(const void *a)
-{
- macaddr empty = { 0 };
- return os_memcmp(a, empty, sizeof(macaddr));
-}
-
-
-static int hostapd_acl_comp(const void *a, const void *b)
-{
- const struct mac_acl_entry *aa = a;
- const struct mac_acl_entry *bb = b;
- return os_memcmp(aa->addr, bb->addr, sizeof(macaddr));
-}
-
-
-static int hostapd_config_read_maclist(const char *fname,
- struct mac_acl_entry **acl, int *num)
-{
- FILE *f;
- char buf[128], *pos;
- int line = 0;
- u8 addr[ETH_ALEN];
- struct mac_acl_entry *newacl;
- int vlan_id;
-
- if (!fname)
- return 0;
-
- f = fopen(fname, "r");
- if (!f) {
- wpa_printf(MSG_ERROR, "MAC list file '%s' not found.", fname);
- return -1;
- }
-
- while (fgets(buf, sizeof(buf), f)) {
- line++;
-
- if (buf[0] == '#')
- continue;
- pos = buf;
- while (*pos != '\0') {
- if (*pos == '\n') {
- *pos = '\0';
- break;
- }
- pos++;
- }
- if (buf[0] == '\0')
- continue;
-
- if (hwaddr_aton(buf, addr)) {
- wpa_printf(MSG_ERROR, "Invalid MAC address '%s' at "
- "line %d in '%s'", buf, line, fname);
- fclose(f);
- return -1;
- }
-
- vlan_id = 0;
- pos = buf;
- while (*pos != '\0' && *pos != ' ' && *pos != '\t')
- pos++;
- while (*pos == ' ' || *pos == '\t')
- pos++;
- if (*pos != '\0')
- vlan_id = atoi(pos);
-
- newacl = os_realloc(*acl, (*num + 1) * sizeof(**acl));
- if (newacl == NULL) {
- wpa_printf(MSG_ERROR, "MAC list reallocation failed");
- fclose(f);
- return -1;
- }
-
- *acl = newacl;
- os_memcpy((*acl)[*num].addr, addr, ETH_ALEN);
- (*acl)[*num].vlan_id = vlan_id;
- (*num)++;
- }
-
- fclose(f);
-
- qsort(*acl, *num, sizeof(**acl), hostapd_acl_comp);
-
- return 0;
-}
-
-
-static int hostapd_config_read_wpa_psk(const char *fname,
- struct hostapd_ssid *ssid)
-{
- FILE *f;
- char buf[128], *pos;
- int line = 0, ret = 0, len, ok;
- u8 addr[ETH_ALEN];
- struct hostapd_wpa_psk *psk;
-
- if (!fname)
- return 0;
-
- f = fopen(fname, "r");
- if (!f) {
- wpa_printf(MSG_ERROR, "WPA PSK file '%s' not found.", fname);
- return -1;
- }
-
- while (fgets(buf, sizeof(buf), f)) {
- line++;
-
- if (buf[0] == '#')
- continue;
- pos = buf;
- while (*pos != '\0') {
- if (*pos == '\n') {
- *pos = '\0';
- break;
- }
- pos++;
- }
- if (buf[0] == '\0')
- continue;
-
- if (hwaddr_aton(buf, addr)) {
- wpa_printf(MSG_ERROR, "Invalid MAC address '%s' on "
- "line %d in '%s'", buf, line, fname);
- ret = -1;
- break;
- }
-
- psk = os_zalloc(sizeof(*psk));
- if (psk == NULL) {
- wpa_printf(MSG_ERROR, "WPA PSK allocation failed");
- ret = -1;
- break;
- }
- if (is_zero_ether_addr(addr))
- psk->group = 1;
- else
- os_memcpy(psk->addr, addr, ETH_ALEN);
-
- pos = buf + 17;
- if (*pos == '\0') {
- wpa_printf(MSG_ERROR, "No PSK on line %d in '%s'",
- line, fname);
- os_free(psk);
- ret = -1;
- break;
- }
- pos++;
-
- ok = 0;
- len = os_strlen(pos);
- if (len == 64 && hexstr2bin(pos, psk->psk, PMK_LEN) == 0)
- ok = 1;
- else if (len >= 8 && len < 64) {
- pbkdf2_sha1(pos, ssid->ssid, ssid->ssid_len,
- 4096, psk->psk, PMK_LEN);
- ok = 1;
- }
- if (!ok) {
- wpa_printf(MSG_ERROR, "Invalid PSK '%s' on line %d in "
- "'%s'", pos, line, fname);
- os_free(psk);
- ret = -1;
- break;
- }
-
- psk->next = ssid->wpa_psk;
- ssid->wpa_psk = psk;
- }
-
- fclose(f);
-
- return ret;
-}
-
-
-int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf)
-{
- struct hostapd_ssid *ssid = &conf->ssid;
-
- if (ssid->wpa_passphrase != NULL) {
- if (ssid->wpa_psk != NULL) {
- wpa_printf(MSG_ERROR, "Warning: both WPA PSK and "
- "passphrase set. Using passphrase.");
- os_free(ssid->wpa_psk);
- }
- ssid->wpa_psk = os_zalloc(sizeof(struct hostapd_wpa_psk));
- if (ssid->wpa_psk == NULL) {
- wpa_printf(MSG_ERROR, "Unable to alloc space for PSK");
- return -1;
- }
- wpa_hexdump_ascii(MSG_DEBUG, "SSID",
- (u8 *) ssid->ssid, ssid->ssid_len);
- wpa_hexdump_ascii(MSG_DEBUG, "PSK (ASCII passphrase)",
- (u8 *) ssid->wpa_passphrase,
- os_strlen(ssid->wpa_passphrase));
- pbkdf2_sha1(ssid->wpa_passphrase,
- ssid->ssid, ssid->ssid_len,
- 4096, ssid->wpa_psk->psk, PMK_LEN);
- wpa_hexdump(MSG_DEBUG, "PSK (from passphrase)",
- ssid->wpa_psk->psk, PMK_LEN);
- ssid->wpa_psk->group = 1;
- }
-
- if (ssid->wpa_psk_file) {
- if (hostapd_config_read_wpa_psk(ssid->wpa_psk_file,
- &conf->ssid))
- return -1;
- }
-
- return 0;
-}
-
-
-#ifdef EAP_SERVER
-static int hostapd_config_read_eap_user(const char *fname,
- struct hostapd_bss_config *conf)
-{
- FILE *f;
- char buf[512], *pos, *start, *pos2;
- int line = 0, ret = 0, num_methods;
- struct hostapd_eap_user *user, *tail = NULL;
-
- if (!fname)
- return 0;
-
- f = fopen(fname, "r");
- if (!f) {
- wpa_printf(MSG_ERROR, "EAP user file '%s' not found.", fname);
- return -1;
- }
-
- /* Lines: "user" METHOD,METHOD2 "password" (password optional) */
- while (fgets(buf, sizeof(buf), f)) {
- line++;
-
- if (buf[0] == '#')
- continue;
- pos = buf;
- while (*pos != '\0') {
- if (*pos == '\n') {
- *pos = '\0';
- break;
- }
- pos++;
- }
- if (buf[0] == '\0')
- continue;
-
- user = NULL;
-
- if (buf[0] != '"' && buf[0] != '*') {
- wpa_printf(MSG_ERROR, "Invalid EAP identity (no \" in "
- "start) on line %d in '%s'", line, fname);
- goto failed;
- }
-
- user = os_zalloc(sizeof(*user));
- if (user == NULL) {
- wpa_printf(MSG_ERROR, "EAP user allocation failed");
- goto failed;
- }
- user->force_version = -1;
-
- if (buf[0] == '*') {
- pos = buf;
- } else {
- pos = buf + 1;
- start = pos;
- while (*pos != '"' && *pos != '\0')
- pos++;
- if (*pos == '\0') {
- wpa_printf(MSG_ERROR, "Invalid EAP identity "
- "(no \" in end) on line %d in '%s'",
- line, fname);
- goto failed;
- }
-
- user->identity = os_malloc(pos - start);
- if (user->identity == NULL) {
- wpa_printf(MSG_ERROR, "Failed to allocate "
- "memory for EAP identity");
- goto failed;
- }
- os_memcpy(user->identity, start, pos - start);
- user->identity_len = pos - start;
-
- if (pos[0] == '"' && pos[1] == '*') {
- user->wildcard_prefix = 1;
- pos++;
- }
- }
- pos++;
- while (*pos == ' ' || *pos == '\t')
- pos++;
-
- if (*pos == '\0') {
- wpa_printf(MSG_ERROR, "No EAP method on line %d in "
- "'%s'", line, fname);
- goto failed;
- }
-
- start = pos;
- while (*pos != ' ' && *pos != '\t' && *pos != '\0')
- pos++;
- if (*pos == '\0') {
- pos = NULL;
- } else {
- *pos = '\0';
- pos++;
- }
- num_methods = 0;
- while (*start) {
- char *pos3 = os_strchr(start, ',');
- if (pos3) {
- *pos3++ = '\0';
- }
- user->methods[num_methods].method =
- eap_server_get_type(
- start,
- &user->methods[num_methods].vendor);
- if (user->methods[num_methods].vendor ==
- EAP_VENDOR_IETF &&
- user->methods[num_methods].method == EAP_TYPE_NONE)
- {
- if (os_strcmp(start, "TTLS-PAP") == 0) {
- user->ttls_auth |= EAP_TTLS_AUTH_PAP;
- goto skip_eap;
- }
- if (os_strcmp(start, "TTLS-CHAP") == 0) {
- user->ttls_auth |= EAP_TTLS_AUTH_CHAP;
- goto skip_eap;
- }
- if (os_strcmp(start, "TTLS-MSCHAP") == 0) {
- user->ttls_auth |=
- EAP_TTLS_AUTH_MSCHAP;
- goto skip_eap;
- }
- if (os_strcmp(start, "TTLS-MSCHAPV2") == 0) {
- user->ttls_auth |=
- EAP_TTLS_AUTH_MSCHAPV2;
- goto skip_eap;
- }
- wpa_printf(MSG_ERROR, "Unsupported EAP type "
- "'%s' on line %d in '%s'",
- start, line, fname);
- goto failed;
- }
-
- num_methods++;
- if (num_methods >= EAP_USER_MAX_METHODS)
- break;
- skip_eap:
- if (pos3 == NULL)
- break;
- start = pos3;
- }
- if (num_methods == 0 && user->ttls_auth == 0) {
- wpa_printf(MSG_ERROR, "No EAP types configured on "
- "line %d in '%s'", line, fname);
- goto failed;
- }
-
- if (pos == NULL)
- goto done;
-
- while (*pos == ' ' || *pos == '\t')
- pos++;
- if (*pos == '\0')
- goto done;
-
- if (os_strncmp(pos, "[ver=0]", 7) == 0) {
- user->force_version = 0;
- goto done;
- }
-
- if (os_strncmp(pos, "[ver=1]", 7) == 0) {
- user->force_version = 1;
- goto done;
- }
-
- if (os_strncmp(pos, "[2]", 3) == 0) {
- user->phase2 = 1;
- goto done;
- }
-
- if (*pos == '"') {
- pos++;
- start = pos;
- while (*pos != '"' && *pos != '\0')
- pos++;
- if (*pos == '\0') {
- wpa_printf(MSG_ERROR, "Invalid EAP password "
- "(no \" in end) on line %d in '%s'",
- line, fname);
- goto failed;
- }
-
- user->password = os_malloc(pos - start);
- if (user->password == NULL) {
- wpa_printf(MSG_ERROR, "Failed to allocate "
- "memory for EAP password");
- goto failed;
- }
- os_memcpy(user->password, start, pos - start);
- user->password_len = pos - start;
-
- pos++;
- } else if (os_strncmp(pos, "hash:", 5) == 0) {
- pos += 5;
- pos2 = pos;
- while (*pos2 != '\0' && *pos2 != ' ' &&
- *pos2 != '\t' && *pos2 != '#')
- pos2++;
- if (pos2 - pos != 32) {
- wpa_printf(MSG_ERROR, "Invalid password hash "
- "on line %d in '%s'", line, fname);
- goto failed;
- }
- user->password = os_malloc(16);
- if (user->password == NULL) {
- wpa_printf(MSG_ERROR, "Failed to allocate "
- "memory for EAP password hash");
- goto failed;
- }
- if (hexstr2bin(pos, user->password, 16) < 0) {
- wpa_printf(MSG_ERROR, "Invalid hash password "
- "on line %d in '%s'", line, fname);
- goto failed;
- }
- user->password_len = 16;
- user->password_hash = 1;
- pos = pos2;
- } else {
- pos2 = pos;
- while (*pos2 != '\0' && *pos2 != ' ' &&
- *pos2 != '\t' && *pos2 != '#')
- pos2++;
- if ((pos2 - pos) & 1) {
- wpa_printf(MSG_ERROR, "Invalid hex password "
- "on line %d in '%s'", line, fname);
- goto failed;
- }
- user->password = os_malloc((pos2 - pos) / 2);
- if (user->password == NULL) {
- wpa_printf(MSG_ERROR, "Failed to allocate "
- "memory for EAP password");
- goto failed;
- }
- if (hexstr2bin(pos, user->password,
- (pos2 - pos) / 2) < 0) {
- wpa_printf(MSG_ERROR, "Invalid hex password "
- "on line %d in '%s'", line, fname);
- goto failed;
- }
- user->password_len = (pos2 - pos) / 2;
- pos = pos2;
- }
-
- while (*pos == ' ' || *pos == '\t')
- pos++;
- if (os_strncmp(pos, "[2]", 3) == 0) {
- user->phase2 = 1;
- }
-
- done:
- if (tail == NULL) {
- tail = conf->eap_user = user;
- } else {
- tail->next = user;
- tail = user;
- }
- continue;
-
- failed:
- if (user) {
- os_free(user->password);
- os_free(user->identity);
- os_free(user);
- }
- ret = -1;
- break;
- }
-
- fclose(f);
-
- return ret;
-}
-#endif /* EAP_SERVER */
-
-
-static int
-hostapd_config_read_radius_addr(struct hostapd_radius_server **server,
- int *num_server, const char *val, int def_port,
- struct hostapd_radius_server **curr_serv)
-{
- struct hostapd_radius_server *nserv;
- int ret;
- static int server_index = 1;
-
- nserv = os_realloc(*server, (*num_server + 1) * sizeof(*nserv));
- if (nserv == NULL)
- return -1;
-
- *server = nserv;
- nserv = &nserv[*num_server];
- (*num_server)++;
- (*curr_serv) = nserv;
-
- os_memset(nserv, 0, sizeof(*nserv));
- nserv->port = def_port;
- ret = hostapd_parse_ip_addr(val, &nserv->addr);
- nserv->index = server_index++;
-
- return ret;
-}
-
-
-static int hostapd_config_parse_key_mgmt(int line, const char *value)
-{
- int val = 0, last;
- char *start, *end, *buf;
-
- buf = os_strdup(value);
- if (buf == NULL)
- return -1;
- start = buf;
-
- while (*start != '\0') {
- while (*start == ' ' || *start == '\t')
- start++;
- if (*start == '\0')
- break;
- end = start;
- while (*end != ' ' && *end != '\t' && *end != '\0')
- end++;
- last = *end == '\0';
- *end = '\0';
- if (os_strcmp(start, "WPA-PSK") == 0)
- val |= WPA_KEY_MGMT_PSK;
- else if (os_strcmp(start, "WPA-EAP") == 0)
- val |= WPA_KEY_MGMT_IEEE8021X;
-#ifdef CONFIG_IEEE80211R
- else if (os_strcmp(start, "FT-PSK") == 0)
- val |= WPA_KEY_MGMT_FT_PSK;
- else if (os_strcmp(start, "FT-EAP") == 0)
- val |= WPA_KEY_MGMT_FT_IEEE8021X;
-#endif /* CONFIG_IEEE80211R */
-#ifdef CONFIG_IEEE80211W
- else if (os_strcmp(start, "WPA-PSK-SHA256") == 0)
- val |= WPA_KEY_MGMT_PSK_SHA256;
- else if (os_strcmp(start, "WPA-EAP-SHA256") == 0)
- val |= WPA_KEY_MGMT_IEEE8021X_SHA256;
-#endif /* CONFIG_IEEE80211W */
- else {
- wpa_printf(MSG_ERROR, "Line %d: invalid key_mgmt '%s'",
- line, start);
- os_free(buf);
- return -1;
- }
-
- if (last)
- break;
- start = end + 1;
- }
-
- os_free(buf);
- if (val == 0) {
- wpa_printf(MSG_ERROR, "Line %d: no key_mgmt values "
- "configured.", line);
- return -1;
- }
-
- return val;
-}
-
-
-static int hostapd_config_parse_cipher(int line, const char *value)
-{
- int val = 0, last;
- char *start, *end, *buf;
-
- buf = os_strdup(value);
- if (buf == NULL)
- return -1;
- start = buf;
-
- while (*start != '\0') {
- while (*start == ' ' || *start == '\t')
- start++;
- if (*start == '\0')
- break;
- end = start;
- while (*end != ' ' && *end != '\t' && *end != '\0')
- end++;
- last = *end == '\0';
- *end = '\0';
- if (os_strcmp(start, "CCMP") == 0)
- val |= WPA_CIPHER_CCMP;
- else if (os_strcmp(start, "TKIP") == 0)
- val |= WPA_CIPHER_TKIP;
- else if (os_strcmp(start, "WEP104") == 0)
- val |= WPA_CIPHER_WEP104;
- else if (os_strcmp(start, "WEP40") == 0)
- val |= WPA_CIPHER_WEP40;
- else if (os_strcmp(start, "NONE") == 0)
- val |= WPA_CIPHER_NONE;
- else {
- wpa_printf(MSG_ERROR, "Line %d: invalid cipher '%s'.",
- line, start);
- os_free(buf);
- return -1;
- }
-
- if (last)
- break;
- start = end + 1;
- }
- os_free(buf);
-
- if (val == 0) {
- wpa_printf(MSG_ERROR, "Line %d: no cipher values configured.",
- line);
- return -1;
- }
- return val;
-}
-
-
-static int hostapd_config_check_bss(struct hostapd_bss_config *bss,
- struct hostapd_config *conf)
-{
- if (bss->ieee802_1x && !bss->eap_server &&
- !bss->radius->auth_servers) {
- wpa_printf(MSG_ERROR, "Invalid IEEE 802.1X configuration (no "
- "EAP authenticator configured).");
- return -1;
- }
-
- if (bss->wpa && (bss->wpa_key_mgmt & WPA_KEY_MGMT_PSK) &&
- bss->ssid.wpa_psk == NULL && bss->ssid.wpa_passphrase == NULL &&
- bss->ssid.wpa_psk_file == NULL) {
- wpa_printf(MSG_ERROR, "WPA-PSK enabled, but PSK or passphrase "
- "is not configured.");
- return -1;
- }
-
- if (hostapd_mac_comp_empty(bss->bssid) != 0) {
- size_t i;
-
- for (i = 0; i < conf->num_bss; i++) {
- if ((&conf->bss[i] != bss) &&
- (hostapd_mac_comp(conf->bss[i].bssid,
- bss->bssid) == 0)) {
- wpa_printf(MSG_ERROR, "Duplicate BSSID " MACSTR
- " on interface '%s' and '%s'.",
- MAC2STR(bss->bssid),
- conf->bss[i].iface, bss->iface);
- return -1;
- }
- }
- }
-
-#ifdef CONFIG_IEEE80211R
- if ((bss->wpa_key_mgmt &
- (WPA_KEY_MGMT_FT_PSK | WPA_KEY_MGMT_FT_IEEE8021X)) &&
- (bss->nas_identifier == NULL ||
- os_strlen(bss->nas_identifier) < 1 ||
- os_strlen(bss->nas_identifier) > FT_R0KH_ID_MAX_LEN)) {
- wpa_printf(MSG_ERROR, "FT (IEEE 802.11r) requires "
- "nas_identifier to be configured as a 1..48 octet "
- "string");
- return -1;
- }
-#endif /* CONFIG_IEEE80211R */
-
-#ifdef CONFIG_IEEE80211N
- if (conf->ieee80211n && bss->wpa &&
- !(bss->wpa_pairwise & WPA_CIPHER_CCMP) &&
- !(bss->rsn_pairwise & WPA_CIPHER_CCMP)) {
- wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) with WPA/WPA2 "
- "requires CCMP to be enabled");
- return -1;
- }
-#endif /* CONFIG_IEEE80211N */
-
- return 0;
-}
-
-
-static int hostapd_config_check(struct hostapd_config *conf)
-{
- size_t i;
-
- if (conf->ieee80211d && (!conf->country[0] || !conf->country[1])) {
- wpa_printf(MSG_ERROR, "Cannot enable IEEE 802.11d without "
- "setting the country_code");
- return -1;
- }
-
- for (i = 0; i < conf->num_bss; i++) {
- if (hostapd_config_check_bss(&conf->bss[i], conf))
- return -1;
- }
-
- return 0;
-}
-
-
-static int hostapd_config_read_wep(struct hostapd_wep_keys *wep, int keyidx,
- char *val)
-{
- size_t len = os_strlen(val);
-
- if (keyidx < 0 || keyidx > 3 || wep->key[keyidx] != NULL)
- return -1;
-
- if (val[0] == '"') {
- if (len < 2 || val[len - 1] != '"')
- return -1;
- len -= 2;
- wep->key[keyidx] = os_malloc(len);
- if (wep->key[keyidx] == NULL)
- return -1;
- os_memcpy(wep->key[keyidx], val + 1, len);
- wep->len[keyidx] = len;
- } else {
- if (len & 1)
- return -1;
- len /= 2;
- wep->key[keyidx] = os_malloc(len);
- if (wep->key[keyidx] == NULL)
- return -1;
- wep->len[keyidx] = len;
- if (hexstr2bin(val, wep->key[keyidx], len) < 0)
- return -1;
- }
-
- wep->keys_set++;
-
- return 0;
-}
-
-
-static int hostapd_parse_rates(int **rate_list, char *val)
-{
- int *list;
- int count;
- char *pos, *end;
-
- os_free(*rate_list);
- *rate_list = NULL;
-
- pos = val;
- count = 0;
- while (*pos != '\0') {
- if (*pos == ' ')
- count++;
- pos++;
- }
-
- list = os_malloc(sizeof(int) * (count + 2));
- if (list == NULL)
- return -1;
- pos = val;
- count = 0;
- while (*pos != '\0') {
- end = os_strchr(pos, ' ');
- if (end)
- *end = '\0';
-
- list[count++] = atoi(pos);
- if (!end)
- break;
- pos = end + 1;
- }
- list[count] = -1;
-
- *rate_list = list;
- return 0;
-}
-
-
-static int hostapd_config_bss(struct hostapd_config *conf, const char *ifname)
-{
- struct hostapd_bss_config *bss;
-
- if (*ifname == '\0')
- return -1;
-
- bss = os_realloc(conf->bss, (conf->num_bss + 1) *
- sizeof(struct hostapd_bss_config));
- if (bss == NULL) {
- wpa_printf(MSG_ERROR, "Failed to allocate memory for "
- "multi-BSS entry");
- return -1;
- }
- conf->bss = bss;
-
- bss = &(conf->bss[conf->num_bss]);
- os_memset(bss, 0, sizeof(*bss));
- bss->radius = os_zalloc(sizeof(*bss->radius));
- if (bss->radius == NULL) {
- wpa_printf(MSG_ERROR, "Failed to allocate memory for "
- "multi-BSS RADIUS data");
- return -1;
- }
-
- conf->num_bss++;
- conf->last_bss = bss;
-
- hostapd_config_defaults_bss(bss);
- os_strlcpy(bss->iface, ifname, sizeof(bss->iface));
- os_memcpy(bss->ssid.vlan, bss->iface, IFNAMSIZ + 1);
-
- return 0;
-}
-
-
-static int valid_cw(int cw)
-{
- return (cw == 1 || cw == 3 || cw == 7 || cw == 15 || cw == 31 ||
- cw == 63 || cw == 127 || cw == 255 || cw == 511 || cw == 1023);
-}
-
-
-enum {
- IEEE80211_TX_QUEUE_DATA0 = 0, /* used for EDCA AC_VO data */
- IEEE80211_TX_QUEUE_DATA1 = 1, /* used for EDCA AC_VI data */
- IEEE80211_TX_QUEUE_DATA2 = 2, /* used for EDCA AC_BE data */
- IEEE80211_TX_QUEUE_DATA3 = 3, /* used for EDCA AC_BK data */
- IEEE80211_TX_QUEUE_DATA4 = 4,
- IEEE80211_TX_QUEUE_AFTER_BEACON = 6,
- IEEE80211_TX_QUEUE_BEACON = 7
-};
-
-static int hostapd_config_tx_queue(struct hostapd_config *conf, char *name,
- char *val)
-{
- int num;
- char *pos;
- struct hostapd_tx_queue_params *queue;
-
- /* skip 'tx_queue_' prefix */
- pos = name + 9;
- if (os_strncmp(pos, "data", 4) == 0 &&
- pos[4] >= '0' && pos[4] <= '9' && pos[5] == '_') {
- num = pos[4] - '0';
- pos += 6;
- } else if (os_strncmp(pos, "after_beacon_", 13) == 0) {
- num = IEEE80211_TX_QUEUE_AFTER_BEACON;
- pos += 13;
- } else if (os_strncmp(pos, "beacon_", 7) == 0) {
- num = IEEE80211_TX_QUEUE_BEACON;
- pos += 7;
- } else {
- wpa_printf(MSG_ERROR, "Unknown tx_queue name '%s'", pos);
- return -1;
- }
-
- queue = &conf->tx_queue[num];
-
- if (os_strcmp(pos, "aifs") == 0) {
- queue->aifs = atoi(val);
- if (queue->aifs < 0 || queue->aifs > 255) {
- wpa_printf(MSG_ERROR, "Invalid AIFS value %d",
- queue->aifs);
- return -1;
- }
- } else if (os_strcmp(pos, "cwmin") == 0) {
- queue->cwmin = atoi(val);
- if (!valid_cw(queue->cwmin)) {
- wpa_printf(MSG_ERROR, "Invalid cwMin value %d",
- queue->cwmin);
- return -1;
- }
- } else if (os_strcmp(pos, "cwmax") == 0) {
- queue->cwmax = atoi(val);
- if (!valid_cw(queue->cwmax)) {
- wpa_printf(MSG_ERROR, "Invalid cwMax value %d",
- queue->cwmax);
- return -1;
- }
- } else if (os_strcmp(pos, "burst") == 0) {
- queue->burst = hostapd_config_read_int10(val);
- } else {
- wpa_printf(MSG_ERROR, "Unknown tx_queue field '%s'", pos);
- return -1;
- }
-
- queue->configured = 1;
-
- return 0;
-}
-
-
-static int hostapd_config_wmm_ac(struct hostapd_config *conf, char *name,
- char *val)
-{
- int num, v;
- char *pos;
- struct hostapd_wmm_ac_params *ac;
-
- /* skip 'wme_ac_' or 'wmm_ac_' prefix */
- pos = name + 7;
- if (os_strncmp(pos, "be_", 3) == 0) {
- num = 0;
- pos += 3;
- } else if (os_strncmp(pos, "bk_", 3) == 0) {
- num = 1;
- pos += 3;
- } else if (os_strncmp(pos, "vi_", 3) == 0) {
- num = 2;
- pos += 3;
- } else if (os_strncmp(pos, "vo_", 3) == 0) {
- num = 3;
- pos += 3;
- } else {
- wpa_printf(MSG_ERROR, "Unknown WMM name '%s'", pos);
- return -1;
- }
-
- ac = &conf->wmm_ac_params[num];
-
- if (os_strcmp(pos, "aifs") == 0) {
- v = atoi(val);
- if (v < 1 || v > 255) {
- wpa_printf(MSG_ERROR, "Invalid AIFS value %d", v);
- return -1;
- }
- ac->aifs = v;
- } else if (os_strcmp(pos, "cwmin") == 0) {
- v = atoi(val);
- if (v < 0 || v > 12) {
- wpa_printf(MSG_ERROR, "Invalid cwMin value %d", v);
- return -1;
- }
- ac->cwmin = v;
- } else if (os_strcmp(pos, "cwmax") == 0) {
- v = atoi(val);
- if (v < 0 || v > 12) {
- wpa_printf(MSG_ERROR, "Invalid cwMax value %d", v);
- return -1;
- }
- ac->cwmax = v;
- } else if (os_strcmp(pos, "txop_limit") == 0) {
- v = atoi(val);
- if (v < 0 || v > 0xffff) {
- wpa_printf(MSG_ERROR, "Invalid txop value %d", v);
- return -1;
- }
- ac->txop_limit = v;
- } else if (os_strcmp(pos, "acm") == 0) {
- v = atoi(val);
- if (v < 0 || v > 1) {
- wpa_printf(MSG_ERROR, "Invalid acm value %d", v);
- return -1;
- }
- ac->admission_control_mandatory = v;
- } else {
- wpa_printf(MSG_ERROR, "Unknown wmm_ac_ field '%s'", pos);
- return -1;
- }
-
- return 0;
-}
-
-
-#ifdef CONFIG_IEEE80211R
-static int add_r0kh(struct hostapd_bss_config *bss, char *value)
-{
- struct ft_remote_r0kh *r0kh;
- char *pos, *next;
-
- r0kh = os_zalloc(sizeof(*r0kh));
- if (r0kh == NULL)
- return -1;
-
- /* 02:01:02:03:04:05 a.example.com 000102030405060708090a0b0c0d0e0f */
- pos = value;
- next = os_strchr(pos, ' ');
- if (next)
- *next++ = '\0';
- if (next == NULL || hwaddr_aton(pos, r0kh->addr)) {
- wpa_printf(MSG_ERROR, "Invalid R0KH MAC address: '%s'", pos);
- os_free(r0kh);
- return -1;
- }
-
- pos = next;
- next = os_strchr(pos, ' ');
- if (next)
- *next++ = '\0';
- if (next == NULL || next - pos > FT_R0KH_ID_MAX_LEN) {
- wpa_printf(MSG_ERROR, "Invalid R0KH-ID: '%s'", pos);
- os_free(r0kh);
- return -1;
- }
- r0kh->id_len = next - pos - 1;
- os_memcpy(r0kh->id, pos, r0kh->id_len);
-
- pos = next;
- if (hexstr2bin(pos, r0kh->key, sizeof(r0kh->key))) {
- wpa_printf(MSG_ERROR, "Invalid R0KH key: '%s'", pos);
- os_free(r0kh);
- return -1;
- }
-
- r0kh->next = bss->r0kh_list;
- bss->r0kh_list = r0kh;
-
- return 0;
-}
-
-
-static int add_r1kh(struct hostapd_bss_config *bss, char *value)
-{
- struct ft_remote_r1kh *r1kh;
- char *pos, *next;
-
- r1kh = os_zalloc(sizeof(*r1kh));
- if (r1kh == NULL)
- return -1;
-
- /* 02:01:02:03:04:05 02:01:02:03:04:05
- * 000102030405060708090a0b0c0d0e0f */
- pos = value;
- next = os_strchr(pos, ' ');
- if (next)
- *next++ = '\0';
- if (next == NULL || hwaddr_aton(pos, r1kh->addr)) {
- wpa_printf(MSG_ERROR, "Invalid R1KH MAC address: '%s'", pos);
- os_free(r1kh);
- return -1;
- }
-
- pos = next;
- next = os_strchr(pos, ' ');
- if (next)
- *next++ = '\0';
- if (next == NULL || hwaddr_aton(pos, r1kh->id)) {
- wpa_printf(MSG_ERROR, "Invalid R1KH-ID: '%s'", pos);
- os_free(r1kh);
- return -1;
- }
-
- pos = next;
- if (hexstr2bin(pos, r1kh->key, sizeof(r1kh->key))) {
- wpa_printf(MSG_ERROR, "Invalid R1KH key: '%s'", pos);
- os_free(r1kh);
- return -1;
- }
-
- r1kh->next = bss->r1kh_list;
- bss->r1kh_list = r1kh;
-
- return 0;
-}
-#endif /* CONFIG_IEEE80211R */
-
-
-#ifdef CONFIG_IEEE80211N
-static int hostapd_config_ht_capab(struct hostapd_config *conf,
- const char *capab)
-{
- if (os_strstr(capab, "[LDPC]"))
- conf->ht_capab |= HT_CAP_INFO_LDPC_CODING_CAP;
- if (os_strstr(capab, "[HT40-]")) {
- conf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
- conf->secondary_channel = -1;
- }
- if (os_strstr(capab, "[HT40+]")) {
- conf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
- conf->secondary_channel = 1;
- }
- if (os_strstr(capab, "[SMPS-STATIC]")) {
- conf->ht_capab &= ~HT_CAP_INFO_SMPS_MASK;
- conf->ht_capab |= HT_CAP_INFO_SMPS_STATIC;
- }
- if (os_strstr(capab, "[SMPS-DYNAMIC]")) {
- conf->ht_capab &= ~HT_CAP_INFO_SMPS_MASK;
- conf->ht_capab |= HT_CAP_INFO_SMPS_DYNAMIC;
- }
- if (os_strstr(capab, "[GF]"))
- conf->ht_capab |= HT_CAP_INFO_GREEN_FIELD;
- if (os_strstr(capab, "[SHORT-GI-20]"))
- conf->ht_capab |= HT_CAP_INFO_SHORT_GI20MHZ;
- if (os_strstr(capab, "[SHORT-GI-40]"))
- conf->ht_capab |= HT_CAP_INFO_SHORT_GI40MHZ;
- if (os_strstr(capab, "[TX-STBC]"))
- conf->ht_capab |= HT_CAP_INFO_TX_STBC;
- if (os_strstr(capab, "[RX-STBC1]")) {
- conf->ht_capab &= ~HT_CAP_INFO_RX_STBC_MASK;
- conf->ht_capab |= HT_CAP_INFO_RX_STBC_1;
- }
- if (os_strstr(capab, "[RX-STBC12]")) {
- conf->ht_capab &= ~HT_CAP_INFO_RX_STBC_MASK;
- conf->ht_capab |= HT_CAP_INFO_RX_STBC_12;
- }
- if (os_strstr(capab, "[RX-STBC123]")) {
- conf->ht_capab &= ~HT_CAP_INFO_RX_STBC_MASK;
- conf->ht_capab |= HT_CAP_INFO_RX_STBC_123;
- }
- if (os_strstr(capab, "[DELAYED-BA]"))
- conf->ht_capab |= HT_CAP_INFO_DELAYED_BA;
- if (os_strstr(capab, "[MAX-AMSDU-7935]"))
- conf->ht_capab |= HT_CAP_INFO_MAX_AMSDU_SIZE;
- if (os_strstr(capab, "[DSSS_CCK-40]"))
- conf->ht_capab |= HT_CAP_INFO_DSSS_CCK40MHZ;
- if (os_strstr(capab, "[PSMP]"))
- conf->ht_capab |= HT_CAP_INFO_PSMP_SUPP;
- if (os_strstr(capab, "[LSIG-TXOP-PROT]"))
- conf->ht_capab |= HT_CAP_INFO_LSIG_TXOP_PROTECT_SUPPORT;
-
- return 0;
-}
-#endif /* CONFIG_IEEE80211N */
-
-
-/**
- * hostapd_config_read - Read and parse a configuration file
- * @fname: Configuration file name (including path, if needed)
- * Returns: Allocated configuration data structure
- */
-struct hostapd_config * hostapd_config_read(const char *fname)
-{
- struct hostapd_config *conf;
- struct hostapd_bss_config *bss;
- FILE *f;
- char buf[256], *pos;
- int line = 0;
- int errors = 0;
- int pairwise;
- size_t i;
-
- f = fopen(fname, "r");
- if (f == NULL) {
- wpa_printf(MSG_ERROR, "Could not open configuration file '%s' "
- "for reading.", fname);
- return NULL;
- }
-
- conf = hostapd_config_defaults();
- if (conf == NULL) {
- fclose(f);
- return NULL;
- }
- bss = conf->last_bss = conf->bss;
-
- while (fgets(buf, sizeof(buf), f)) {
- bss = conf->last_bss;
- line++;
-
- if (buf[0] == '#')
- continue;
- pos = buf;
- while (*pos != '\0') {
- if (*pos == '\n') {
- *pos = '\0';
- break;
- }
- pos++;
- }
- if (buf[0] == '\0')
- continue;
-
- pos = os_strchr(buf, '=');
- if (pos == NULL) {
- wpa_printf(MSG_ERROR, "Line %d: invalid line '%s'",
- line, buf);
- errors++;
- continue;
- }
- *pos = '\0';
- pos++;
-
- if (os_strcmp(buf, "interface") == 0) {
- os_strlcpy(conf->bss[0].iface, pos,
- sizeof(conf->bss[0].iface));
- } else if (os_strcmp(buf, "bridge") == 0) {
- os_strlcpy(bss->bridge, pos, sizeof(bss->bridge));
- } else if (os_strcmp(buf, "driver") == 0) {
- int j;
- /* clear to get error below if setting is invalid */
- conf->driver = NULL;
- for (j = 0; hostapd_drivers[j]; j++) {
- if (os_strcmp(pos, hostapd_drivers[j]->name) ==
- 0) {
- conf->driver = hostapd_drivers[j];
- break;
- }
- }
- if (conf->driver == NULL) {
- wpa_printf(MSG_ERROR, "Line %d: invalid/"
- "unknown driver '%s'", line, pos);
- errors++;
- }
- } else if (os_strcmp(buf, "debug") == 0) {
- wpa_printf(MSG_DEBUG, "Line %d: DEPRECATED: 'debug' "
- "configuration variable is not used "
- "anymore", line);
- } else if (os_strcmp(buf, "logger_syslog_level") == 0) {
- bss->logger_syslog_level = atoi(pos);
- } else if (os_strcmp(buf, "logger_stdout_level") == 0) {
- bss->logger_stdout_level = atoi(pos);
- } else if (os_strcmp(buf, "logger_syslog") == 0) {
- bss->logger_syslog = atoi(pos);
- } else if (os_strcmp(buf, "logger_stdout") == 0) {
- bss->logger_stdout = atoi(pos);
- } else if (os_strcmp(buf, "dump_file") == 0) {
- bss->dump_log_name = os_strdup(pos);
- } else if (os_strcmp(buf, "ssid") == 0) {
- bss->ssid.ssid_len = os_strlen(pos);
- if (bss->ssid.ssid_len > HOSTAPD_MAX_SSID_LEN ||
- bss->ssid.ssid_len < 1) {
- wpa_printf(MSG_ERROR, "Line %d: invalid SSID "
- "'%s'", line, pos);
- errors++;
- } else {
- os_memcpy(bss->ssid.ssid, pos,
- bss->ssid.ssid_len);
- bss->ssid.ssid[bss->ssid.ssid_len] = '\0';
- bss->ssid.ssid_set = 1;
- }
- } else if (os_strcmp(buf, "macaddr_acl") == 0) {
- bss->macaddr_acl = atoi(pos);
- if (bss->macaddr_acl != ACCEPT_UNLESS_DENIED &&
- bss->macaddr_acl != DENY_UNLESS_ACCEPTED &&
- bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH) {
- wpa_printf(MSG_ERROR, "Line %d: unknown "
- "macaddr_acl %d",
- line, bss->macaddr_acl);
- }
- } else if (os_strcmp(buf, "accept_mac_file") == 0) {
- if (hostapd_config_read_maclist(pos, &bss->accept_mac,
- &bss->num_accept_mac))
- {
- wpa_printf(MSG_ERROR, "Line %d: Failed to "
- "read accept_mac_file '%s'",
- line, pos);
- errors++;
- }
- } else if (os_strcmp(buf, "deny_mac_file") == 0) {
- if (hostapd_config_read_maclist(pos, &bss->deny_mac,
- &bss->num_deny_mac)) {
- wpa_printf(MSG_ERROR, "Line %d: Failed to "
- "read deny_mac_file '%s'",
- line, pos);
- errors++;
- }
- } else if (os_strcmp(buf, "ap_max_inactivity") == 0) {
- bss->ap_max_inactivity = atoi(pos);
- } else if (os_strcmp(buf, "country_code") == 0) {
- os_memcpy(conf->country, pos, 2);
- /* FIX: make this configurable */
- conf->country[2] = ' ';
- } else if (os_strcmp(buf, "ieee80211d") == 0) {
- conf->ieee80211d = atoi(pos);
- } else if (os_strcmp(buf, "ieee8021x") == 0) {
- bss->ieee802_1x = atoi(pos);
- } else if (os_strcmp(buf, "eapol_version") == 0) {
- bss->eapol_version = atoi(pos);
- if (bss->eapol_version < 1 ||
- bss->eapol_version > 2) {
- wpa_printf(MSG_ERROR, "Line %d: invalid EAPOL "
- "version (%d): '%s'.",
- line, bss->eapol_version, pos);
- errors++;
- } else
- wpa_printf(MSG_DEBUG, "eapol_version=%d",
- bss->eapol_version);
-#ifdef EAP_SERVER
- } else if (os_strcmp(buf, "eap_authenticator") == 0) {
- bss->eap_server = atoi(pos);
- wpa_printf(MSG_ERROR, "Line %d: obsolete "
- "eap_authenticator used; this has been "
- "renamed to eap_server", line);
- } else if (os_strcmp(buf, "eap_server") == 0) {
- bss->eap_server = atoi(pos);
- } else if (os_strcmp(buf, "eap_user_file") == 0) {
- if (hostapd_config_read_eap_user(pos, bss))
- errors++;
- } else if (os_strcmp(buf, "ca_cert") == 0) {
- os_free(bss->ca_cert);
- bss->ca_cert = os_strdup(pos);
- } else if (os_strcmp(buf, "server_cert") == 0) {
- os_free(bss->server_cert);
- bss->server_cert = os_strdup(pos);
- } else if (os_strcmp(buf, "private_key") == 0) {
- os_free(bss->private_key);
- bss->private_key = os_strdup(pos);
- } else if (os_strcmp(buf, "private_key_passwd") == 0) {
- os_free(bss->private_key_passwd);
- bss->private_key_passwd = os_strdup(pos);
- } else if (os_strcmp(buf, "check_crl") == 0) {
- bss->check_crl = atoi(pos);
- } else if (os_strcmp(buf, "dh_file") == 0) {
- os_free(bss->dh_file);
- bss->dh_file = os_strdup(pos);
-#ifdef EAP_FAST
- } else if (os_strcmp(buf, "pac_opaque_encr_key") == 0) {
- os_free(bss->pac_opaque_encr_key);
- bss->pac_opaque_encr_key = os_malloc(16);
- if (bss->pac_opaque_encr_key == NULL) {
- wpa_printf(MSG_ERROR, "Line %d: No memory for "
- "pac_opaque_encr_key", line);
- errors++;
- } else if (hexstr2bin(pos, bss->pac_opaque_encr_key,
- 16)) {
- wpa_printf(MSG_ERROR, "Line %d: Invalid "
- "pac_opaque_encr_key", line);
- errors++;
- }
- } else if (os_strcmp(buf, "eap_fast_a_id") == 0) {
- size_t idlen = os_strlen(pos);
- if (idlen & 1) {
- wpa_printf(MSG_ERROR, "Line %d: Invalid "
- "eap_fast_a_id", line);
- errors++;
- } else {
- os_free(bss->eap_fast_a_id);
- bss->eap_fast_a_id = os_malloc(idlen / 2);
- if (bss->eap_fast_a_id == NULL ||
- hexstr2bin(pos, bss->eap_fast_a_id,
- idlen / 2)) {
- wpa_printf(MSG_ERROR, "Line %d: "
- "Failed to parse "
- "eap_fast_a_id", line);
- errors++;
- } else
- bss->eap_fast_a_id_len = idlen / 2;
- }
- } else if (os_strcmp(buf, "eap_fast_a_id_info") == 0) {
- os_free(bss->eap_fast_a_id_info);
- bss->eap_fast_a_id_info = os_strdup(pos);
- } else if (os_strcmp(buf, "eap_fast_prov") == 0) {
- bss->eap_fast_prov = atoi(pos);
- } else if (os_strcmp(buf, "pac_key_lifetime") == 0) {
- bss->pac_key_lifetime = atoi(pos);
- } else if (os_strcmp(buf, "pac_key_refresh_time") == 0) {
- bss->pac_key_refresh_time = atoi(pos);
-#endif /* EAP_FAST */
-#ifdef EAP_SIM
- } else if (os_strcmp(buf, "eap_sim_db") == 0) {
- os_free(bss->eap_sim_db);
- bss->eap_sim_db = os_strdup(pos);
- } else if (os_strcmp(buf, "eap_sim_aka_result_ind") == 0) {
- bss->eap_sim_aka_result_ind = atoi(pos);
-#endif /* EAP_SIM */
-#ifdef EAP_TNC
- } else if (os_strcmp(buf, "tnc") == 0) {
- bss->tnc = atoi(pos);
-#endif /* EAP_TNC */
-#endif /* EAP_SERVER */
- } else if (os_strcmp(buf, "eap_message") == 0) {
- char *term;
- bss->eap_req_id_text = os_strdup(pos);
- if (bss->eap_req_id_text == NULL) {
- wpa_printf(MSG_ERROR, "Line %d: Failed to "
- "allocate memory for "
- "eap_req_id_text", line);
- errors++;
- continue;
- }
- bss->eap_req_id_text_len =
- os_strlen(bss->eap_req_id_text);
- term = os_strstr(bss->eap_req_id_text, "\\0");
- if (term) {
- *term++ = '\0';
- os_memmove(term, term + 1,
- bss->eap_req_id_text_len -
- (term - bss->eap_req_id_text) - 1);
- bss->eap_req_id_text_len--;
- }
- } else if (os_strcmp(buf, "wep_key_len_broadcast") == 0) {
- bss->default_wep_key_len = atoi(pos);
- if (bss->default_wep_key_len > 13) {
- wpa_printf(MSG_ERROR, "Line %d: invalid WEP "
- "key len %lu (= %lu bits)", line,
- (unsigned long)
- bss->default_wep_key_len,
- (unsigned long)
- bss->default_wep_key_len * 8);
- errors++;
- }
- } else if (os_strcmp(buf, "wep_key_len_unicast") == 0) {
- bss->individual_wep_key_len = atoi(pos);
- if (bss->individual_wep_key_len < 0 ||
- bss->individual_wep_key_len > 13) {
- wpa_printf(MSG_ERROR, "Line %d: invalid WEP "
- "key len %d (= %d bits)", line,
- bss->individual_wep_key_len,
- bss->individual_wep_key_len * 8);
- errors++;
- }
- } else if (os_strcmp(buf, "wep_rekey_period") == 0) {
- bss->wep_rekeying_period = atoi(pos);
- if (bss->wep_rekeying_period < 0) {
- wpa_printf(MSG_ERROR, "Line %d: invalid "
- "period %d",
- line, bss->wep_rekeying_period);
- errors++;
- }
- } else if (os_strcmp(buf, "eap_reauth_period") == 0) {
- bss->eap_reauth_period = atoi(pos);
- if (bss->eap_reauth_period < 0) {
- wpa_printf(MSG_ERROR, "Line %d: invalid "
- "period %d",
- line, bss->eap_reauth_period);
- errors++;
- }
- } else if (os_strcmp(buf, "eapol_key_index_workaround") == 0) {
- bss->eapol_key_index_workaround = atoi(pos);
-#ifdef CONFIG_IAPP
- } else if (os_strcmp(buf, "iapp_interface") == 0) {
- bss->ieee802_11f = 1;
- os_strlcpy(bss->iapp_iface, pos,
- sizeof(bss->iapp_iface));
-#endif /* CONFIG_IAPP */
- } else if (os_strcmp(buf, "own_ip_addr") == 0) {
- if (hostapd_parse_ip_addr(pos, &bss->own_ip_addr)) {
- wpa_printf(MSG_ERROR, "Line %d: invalid IP "
- "address '%s'", line, pos);
- errors++;
- }
- } else if (os_strcmp(buf, "nas_identifier") == 0) {
- bss->nas_identifier = os_strdup(pos);
- } else if (os_strcmp(buf, "auth_server_addr") == 0) {
- if (hostapd_config_read_radius_addr(
- &bss->radius->auth_servers,
- &bss->radius->num_auth_servers, pos, 1812,
- &bss->radius->auth_server)) {
- wpa_printf(MSG_ERROR, "Line %d: invalid IP "
- "address '%s'", line, pos);
- errors++;
- }
- } else if (bss->radius->auth_server &&
- os_strcmp(buf, "auth_server_port") == 0) {
- bss->radius->auth_server->port = atoi(pos);
- } else if (bss->radius->auth_server &&
- os_strcmp(buf, "auth_server_shared_secret") == 0) {
- int len = os_strlen(pos);
- if (len == 0) {
- /* RFC 2865, Ch. 3 */
- wpa_printf(MSG_ERROR, "Line %d: empty shared "
- "secret is not allowed.", line);
- errors++;
- }
- bss->radius->auth_server->shared_secret =
- (u8 *) os_strdup(pos);
- bss->radius->auth_server->shared_secret_len = len;
- } else if (os_strcmp(buf, "acct_server_addr") == 0) {
- if (hostapd_config_read_radius_addr(
- &bss->radius->acct_servers,
- &bss->radius->num_acct_servers, pos, 1813,
- &bss->radius->acct_server)) {
- wpa_printf(MSG_ERROR, "Line %d: invalid IP "
- "address '%s'", line, pos);
- errors++;
- }
- } else if (bss->radius->acct_server &&
- os_strcmp(buf, "acct_server_port") == 0) {
- bss->radius->acct_server->port = atoi(pos);
- } else if (bss->radius->acct_server &&
- os_strcmp(buf, "acct_server_shared_secret") == 0) {
- int len = os_strlen(pos);
- if (len == 0) {
- /* RFC 2865, Ch. 3 */
- wpa_printf(MSG_ERROR, "Line %d: empty shared "
- "secret is not allowed.", line);
- errors++;
- }
- bss->radius->acct_server->shared_secret =
- (u8 *) os_strdup(pos);
- bss->radius->acct_server->shared_secret_len = len;
- } else if (os_strcmp(buf, "radius_retry_primary_interval") ==
- 0) {
- bss->radius->retry_primary_interval = atoi(pos);
- } else if (os_strcmp(buf, "radius_acct_interim_interval") == 0)
- {
- bss->radius->acct_interim_interval = atoi(pos);
- } else if (os_strcmp(buf, "auth_algs") == 0) {
- bss->auth_algs = atoi(pos);
- if (bss->auth_algs == 0) {
- wpa_printf(MSG_ERROR, "Line %d: no "
- "authentication algorithms allowed",
- line);
- errors++;
- }
- } else if (os_strcmp(buf, "max_num_sta") == 0) {
- bss->max_num_sta = atoi(pos);
- if (bss->max_num_sta < 0 ||
- bss->max_num_sta > MAX_STA_COUNT) {
- wpa_printf(MSG_ERROR, "Line %d: Invalid "
- "max_num_sta=%d; allowed range "
- "0..%d", line, bss->max_num_sta,
- MAX_STA_COUNT);
- errors++;
- }
- } else if (os_strcmp(buf, "wpa") == 0) {
- bss->wpa = atoi(pos);
- } else if (os_strcmp(buf, "wpa_group_rekey") == 0) {
- bss->wpa_group_rekey = atoi(pos);
- } else if (os_strcmp(buf, "wpa_strict_rekey") == 0) {
- bss->wpa_strict_rekey = atoi(pos);
- } else if (os_strcmp(buf, "wpa_gmk_rekey") == 0) {
- bss->wpa_gmk_rekey = atoi(pos);
- } else if (os_strcmp(buf, "wpa_ptk_rekey") == 0) {
- bss->wpa_ptk_rekey = atoi(pos);
- } else if (os_strcmp(buf, "wpa_passphrase") == 0) {
- int len = os_strlen(pos);
- if (len < 8 || len > 63) {
- wpa_printf(MSG_ERROR, "Line %d: invalid WPA "
- "passphrase length %d (expected "
- "8..63)", line, len);
- errors++;
- } else {
- os_free(bss->ssid.wpa_passphrase);
- bss->ssid.wpa_passphrase = os_strdup(pos);
- }
- } else if (os_strcmp(buf, "wpa_psk") == 0) {
- os_free(bss->ssid.wpa_psk);
- bss->ssid.wpa_psk =
- os_zalloc(sizeof(struct hostapd_wpa_psk));
- if (bss->ssid.wpa_psk == NULL)
- errors++;
- else if (hexstr2bin(pos, bss->ssid.wpa_psk->psk,
- PMK_LEN) ||
- pos[PMK_LEN * 2] != '\0') {
- wpa_printf(MSG_ERROR, "Line %d: Invalid PSK "
- "'%s'.", line, pos);
- errors++;
- } else {
- bss->ssid.wpa_psk->group = 1;
- }
- } else if (os_strcmp(buf, "wpa_psk_file") == 0) {
- os_free(bss->ssid.wpa_psk_file);
- bss->ssid.wpa_psk_file = os_strdup(pos);
- if (!bss->ssid.wpa_psk_file) {
- wpa_printf(MSG_ERROR, "Line %d: allocation "
- "failed", line);
- errors++;
- }
- } else if (os_strcmp(buf, "wpa_key_mgmt") == 0) {
- bss->wpa_key_mgmt =
- hostapd_config_parse_key_mgmt(line, pos);
- if (bss->wpa_key_mgmt == -1)
- errors++;
- } else if (os_strcmp(buf, "wpa_pairwise") == 0) {
- bss->wpa_pairwise =
- hostapd_config_parse_cipher(line, pos);
- if (bss->wpa_pairwise == -1 ||
- bss->wpa_pairwise == 0)
- errors++;
- else if (bss->wpa_pairwise &
- (WPA_CIPHER_NONE | WPA_CIPHER_WEP40 |
- WPA_CIPHER_WEP104)) {
- wpa_printf(MSG_ERROR, "Line %d: unsupported "
- "pairwise cipher suite '%s'",
- bss->wpa_pairwise, pos);
- errors++;
- }
- } else if (os_strcmp(buf, "rsn_pairwise") == 0) {
- bss->rsn_pairwise =
- hostapd_config_parse_cipher(line, pos);
- if (bss->rsn_pairwise == -1 ||
- bss->rsn_pairwise == 0)
- errors++;
- else if (bss->rsn_pairwise &
- (WPA_CIPHER_NONE | WPA_CIPHER_WEP40 |
- WPA_CIPHER_WEP104)) {
- wpa_printf(MSG_ERROR, "Line %d: unsupported "
- "pairwise cipher suite '%s'",
- bss->rsn_pairwise, pos);
- errors++;
- }
-#ifdef CONFIG_RSN_PREAUTH
- } else if (os_strcmp(buf, "rsn_preauth") == 0) {
- bss->rsn_preauth = atoi(pos);
- } else if (os_strcmp(buf, "rsn_preauth_interfaces") == 0) {
- bss->rsn_preauth_interfaces = os_strdup(pos);
-#endif /* CONFIG_RSN_PREAUTH */
-#ifdef CONFIG_PEERKEY
- } else if (os_strcmp(buf, "peerkey") == 0) {
- bss->peerkey = atoi(pos);
-#endif /* CONFIG_PEERKEY */
-#ifdef CONFIG_IEEE80211R
- } else if (os_strcmp(buf, "mobility_domain") == 0) {
- if (os_strlen(pos) != 2 * MOBILITY_DOMAIN_ID_LEN ||
- hexstr2bin(pos, bss->mobility_domain,
- MOBILITY_DOMAIN_ID_LEN) != 0) {
- wpa_printf(MSG_DEBUG, "Line %d: Invalid "
- "mobility_domain '%s'", line, pos);
- errors++;
- continue;
- }
- } else if (os_strcmp(buf, "r1_key_holder") == 0) {
- if (os_strlen(pos) != 2 * FT_R1KH_ID_LEN ||
- hexstr2bin(pos, bss->r1_key_holder,
- FT_R1KH_ID_LEN) != 0) {
- wpa_printf(MSG_DEBUG, "Line %d: Invalid "
- "r1_key_holder '%s'", line, pos);
- errors++;
- continue;
- }
- } else if (os_strcmp(buf, "r0_key_lifetime") == 0) {
- bss->r0_key_lifetime = atoi(pos);
- } else if (os_strcmp(buf, "reassociation_deadline") == 0) {
- bss->reassociation_deadline = atoi(pos);
- } else if (os_strcmp(buf, "r0kh") == 0) {
- if (add_r0kh(bss, pos) < 0) {
- wpa_printf(MSG_DEBUG, "Line %d: Invalid "
- "r0kh '%s'", line, pos);
- errors++;
- continue;
- }
- } else if (os_strcmp(buf, "r1kh") == 0) {
- if (add_r1kh(bss, pos) < 0) {
- wpa_printf(MSG_DEBUG, "Line %d: Invalid "
- "r1kh '%s'", line, pos);
- errors++;
- continue;
- }
- } else if (os_strcmp(buf, "pmk_r1_push") == 0) {
- bss->pmk_r1_push = atoi(pos);
-#endif /* CONFIG_IEEE80211R */
- } else if (os_strcmp(buf, "ctrl_interface") == 0) {
- os_free(bss->ctrl_interface);
- bss->ctrl_interface = os_strdup(pos);
- } else if (os_strcmp(buf, "ctrl_interface_group") == 0) {
-#ifndef CONFIG_NATIVE_WINDOWS
- struct group *grp;
- char *endp;
- const char *group = pos;
-
- grp = getgrnam(group);
- if (grp) {
- bss->ctrl_interface_gid = grp->gr_gid;
- bss->ctrl_interface_gid_set = 1;
- wpa_printf(MSG_DEBUG, "ctrl_interface_group=%d"
- " (from group name '%s')",
- bss->ctrl_interface_gid, group);
- continue;
- }
-
- /* Group name not found - try to parse this as gid */
- bss->ctrl_interface_gid = strtol(group, &endp, 10);
- if (*group == '\0' || *endp != '\0') {
- wpa_printf(MSG_DEBUG, "Line %d: Invalid group "
- "'%s'", line, group);
- errors++;
- continue;
- }
- bss->ctrl_interface_gid_set = 1;
- wpa_printf(MSG_DEBUG, "ctrl_interface_group=%d",
- bss->ctrl_interface_gid);
-#endif /* CONFIG_NATIVE_WINDOWS */
-#ifdef RADIUS_SERVER
- } else if (os_strcmp(buf, "radius_server_clients") == 0) {
- os_free(bss->radius_server_clients);
- bss->radius_server_clients = os_strdup(pos);
- } else if (os_strcmp(buf, "radius_server_auth_port") == 0) {
- bss->radius_server_auth_port = atoi(pos);
- } else if (os_strcmp(buf, "radius_server_ipv6") == 0) {
- bss->radius_server_ipv6 = atoi(pos);
-#endif /* RADIUS_SERVER */
- } else if (os_strcmp(buf, "test_socket") == 0) {
- os_free(bss->test_socket);
- bss->test_socket = os_strdup(pos);
- } else if (os_strcmp(buf, "use_pae_group_addr") == 0) {
- bss->use_pae_group_addr = atoi(pos);
- } else if (os_strcmp(buf, "hw_mode") == 0) {
- if (os_strcmp(pos, "a") == 0)
- conf->hw_mode = HOSTAPD_MODE_IEEE80211A;
- else if (os_strcmp(pos, "b") == 0)
- conf->hw_mode = HOSTAPD_MODE_IEEE80211B;
- else if (os_strcmp(pos, "g") == 0)
- conf->hw_mode = HOSTAPD_MODE_IEEE80211G;
- else {
- wpa_printf(MSG_ERROR, "Line %d: unknown "
- "hw_mode '%s'", line, pos);
- errors++;
- }
- } else if (os_strcmp(buf, "channel") == 0) {
- conf->channel = atoi(pos);
- } else if (os_strcmp(buf, "beacon_int") == 0) {
- int val = atoi(pos);
- /* MIB defines range as 1..65535, but very small values
- * cause problems with the current implementation.
- * Since it is unlikely that this small numbers are
- * useful in real life scenarios, do not allow beacon
- * period to be set below 15 TU. */
- if (val < 15 || val > 65535) {
- wpa_printf(MSG_ERROR, "Line %d: invalid "
- "beacon_int %d (expected "
- "15..65535)", line, val);
- errors++;
- } else
- conf->beacon_int = val;
- } else if (os_strcmp(buf, "dtim_period") == 0) {
- bss->dtim_period = atoi(pos);
- if (bss->dtim_period < 1 || bss->dtim_period > 255) {
- wpa_printf(MSG_ERROR, "Line %d: invalid "
- "dtim_period %d",
- line, bss->dtim_period);
- errors++;
- }
- } else if (os_strcmp(buf, "rts_threshold") == 0) {
- conf->rts_threshold = atoi(pos);
- if (conf->rts_threshold < 0 ||
- conf->rts_threshold > 2347) {
- wpa_printf(MSG_ERROR, "Line %d: invalid "
- "rts_threshold %d",
- line, conf->rts_threshold);
- errors++;
- }
- } else if (os_strcmp(buf, "fragm_threshold") == 0) {
- conf->fragm_threshold = atoi(pos);
- if (conf->fragm_threshold < 256 ||
- conf->fragm_threshold > 2346) {
- wpa_printf(MSG_ERROR, "Line %d: invalid "
- "fragm_threshold %d",
- line, conf->fragm_threshold);
- errors++;
- }
- } else if (os_strcmp(buf, "send_probe_response") == 0) {
- int val = atoi(pos);
- if (val != 0 && val != 1) {
- wpa_printf(MSG_ERROR, "Line %d: invalid "
- "send_probe_response %d (expected "
- "0 or 1)", line, val);
- } else
- conf->send_probe_response = val;
- } else if (os_strcmp(buf, "supported_rates") == 0) {
- if (hostapd_parse_rates(&conf->supported_rates, pos)) {
- wpa_printf(MSG_ERROR, "Line %d: invalid rate "
- "list", line);
- errors++;
- }
- } else if (os_strcmp(buf, "basic_rates") == 0) {
- if (hostapd_parse_rates(&conf->basic_rates, pos)) {
- wpa_printf(MSG_ERROR, "Line %d: invalid rate "
- "list", line);
- errors++;
- }
- } else if (os_strcmp(buf, "preamble") == 0) {
- if (atoi(pos))
- conf->preamble = SHORT_PREAMBLE;
- else
- conf->preamble = LONG_PREAMBLE;
- } else if (os_strcmp(buf, "ignore_broadcast_ssid") == 0) {
- bss->ignore_broadcast_ssid = atoi(pos);
- } else if (os_strcmp(buf, "bridge_packets") == 0) {
- conf->bridge_packets = atoi(pos);
- } else if (os_strcmp(buf, "wep_default_key") == 0) {
- bss->ssid.wep.idx = atoi(pos);
- if (bss->ssid.wep.idx > 3) {
- wpa_printf(MSG_ERROR, "Invalid "
- "wep_default_key index %d",
- bss->ssid.wep.idx);
- errors++;
- }
- } else if (os_strcmp(buf, "wep_key0") == 0 ||
- os_strcmp(buf, "wep_key1") == 0 ||
- os_strcmp(buf, "wep_key2") == 0 ||
- os_strcmp(buf, "wep_key3") == 0) {
- if (hostapd_config_read_wep(&bss->ssid.wep,
- buf[7] - '0', pos)) {
- wpa_printf(MSG_ERROR, "Line %d: invalid WEP "
- "key '%s'", line, buf);
- errors++;
- }
- } else if (os_strcmp(buf, "dynamic_vlan") == 0) {
- bss->ssid.dynamic_vlan = atoi(pos);
- } else if (os_strcmp(buf, "vlan_file") == 0) {
- if (hostapd_config_read_vlan_file(bss, pos)) {
- wpa_printf(MSG_ERROR, "Line %d: failed to "
- "read VLAN file '%s'", line, pos);
- errors++;
- }
-#ifdef CONFIG_FULL_DYNAMIC_VLAN
- } else if (os_strcmp(buf, "vlan_tagged_interface") == 0) {
- bss->ssid.vlan_tagged_interface = os_strdup(pos);
-#endif /* CONFIG_FULL_DYNAMIC_VLAN */
- } else if (os_strcmp(buf, "passive_scan_interval") == 0) {
- conf->passive_scan_interval = atoi(pos);
- } else if (os_strcmp(buf, "passive_scan_listen") == 0) {
- conf->passive_scan_listen = atoi(pos);
- } else if (os_strcmp(buf, "passive_scan_mode") == 0) {
- conf->passive_scan_mode = atoi(pos);
- } else if (os_strcmp(buf, "ap_table_max_size") == 0) {
- conf->ap_table_max_size = atoi(pos);
- } else if (os_strcmp(buf, "ap_table_expiration_time") == 0) {
- conf->ap_table_expiration_time = atoi(pos);
- } else if (os_strncmp(buf, "tx_queue_", 9) == 0) {
- if (hostapd_config_tx_queue(conf, buf, pos)) {
- wpa_printf(MSG_ERROR, "Line %d: invalid TX "
- "queue item", line);
- errors++;
- }
- } else if (os_strcmp(buf, "wme_enabled") == 0 ||
- os_strcmp(buf, "wmm_enabled") == 0) {
- bss->wmm_enabled = atoi(pos);
- } else if (os_strncmp(buf, "wme_ac_", 7) == 0 ||
- os_strncmp(buf, "wmm_ac_", 7) == 0) {
- if (hostapd_config_wmm_ac(conf, buf, pos)) {
- wpa_printf(MSG_ERROR, "Line %d: invalid WMM "
- "ac item", line);
- errors++;
- }
- } else if (os_strcmp(buf, "bss") == 0) {
- if (hostapd_config_bss(conf, pos)) {
- wpa_printf(MSG_ERROR, "Line %d: invalid bss "
- "item", line);
- errors++;
- }
- } else if (os_strcmp(buf, "bssid") == 0) {
- if (bss == conf->bss &&
- (!conf->driver || !conf->driver->init_bssid)) {
- wpa_printf(MSG_ERROR, "Line %d: bssid item "
- "not allowed for the default "
- "interface and this driver", line);
- errors++;
- } else if (hwaddr_aton(pos, bss->bssid)) {
- wpa_printf(MSG_ERROR, "Line %d: invalid bssid "
- "item", line);
- errors++;
- }
-#ifdef CONFIG_IEEE80211W
- } else if (os_strcmp(buf, "ieee80211w") == 0) {
- bss->ieee80211w = atoi(pos);
- } else if (os_strcmp(buf, "assoc_sa_query_max_timeout") == 0) {
- bss->assoc_sa_query_max_timeout = atoi(pos);
- if (bss->assoc_sa_query_max_timeout == 0) {
- wpa_printf(MSG_ERROR, "Line %d: invalid "
- "assoc_sa_query_max_timeout", line);
- errors++;
- }
- } else if (os_strcmp(buf, "assoc_sa_query_retry_timeout") == 0)
- {
- bss->assoc_sa_query_retry_timeout = atoi(pos);
- if (bss->assoc_sa_query_retry_timeout == 0) {
- wpa_printf(MSG_ERROR, "Line %d: invalid "
- "assoc_sa_query_retry_timeout",
- line);
- errors++;
- }
-#endif /* CONFIG_IEEE80211W */
-#ifdef CONFIG_IEEE80211N
- } else if (os_strcmp(buf, "ieee80211n") == 0) {
- conf->ieee80211n = atoi(pos);
- } else if (os_strcmp(buf, "ht_capab") == 0) {
- if (hostapd_config_ht_capab(conf, pos) < 0) {
- wpa_printf(MSG_ERROR, "Line %d: invalid "
- "ht_capab", line);
- errors++;
- }
-#endif /* CONFIG_IEEE80211N */
- } else if (os_strcmp(buf, "max_listen_interval") == 0) {
- bss->max_listen_interval = atoi(pos);
- } else if (os_strcmp(buf, "okc") == 0) {
- bss->okc = atoi(pos);
-#ifdef CONFIG_WPS
- } else if (os_strcmp(buf, "wps_state") == 0) {
- bss->wps_state = atoi(pos);
- if (bss->wps_state < 0 || bss->wps_state > 2) {
- wpa_printf(MSG_ERROR, "Line %d: invalid "
- "wps_state", line);
- errors++;
- }
- } else if (os_strcmp(buf, "ap_setup_locked") == 0) {
- bss->ap_setup_locked = atoi(pos);
- } else if (os_strcmp(buf, "uuid") == 0) {
- if (uuid_str2bin(pos, bss->uuid)) {
- wpa_printf(MSG_ERROR, "Line %d: invalid UUID",
- line);
- errors++;
- }
- } else if (os_strcmp(buf, "wps_pin_requests") == 0) {
- os_free(bss->wps_pin_requests);
- bss->wps_pin_requests = os_strdup(pos);
- } else if (os_strcmp(buf, "device_name") == 0) {
- if (os_strlen(pos) > 32) {
- wpa_printf(MSG_ERROR, "Line %d: Too long "
- "device_name", line);
- errors++;
- }
- os_free(bss->device_name);
- bss->device_name = os_strdup(pos);
- } else if (os_strcmp(buf, "manufacturer") == 0) {
- if (os_strlen(pos) > 64) {
- wpa_printf(MSG_ERROR, "Line %d: Too long "
- "manufacturer", line);
- errors++;
- }
- os_free(bss->manufacturer);
- bss->manufacturer = os_strdup(pos);
- } else if (os_strcmp(buf, "model_name") == 0) {
- if (os_strlen(pos) > 32) {
- wpa_printf(MSG_ERROR, "Line %d: Too long "
- "model_name", line);
- errors++;
- }
- os_free(bss->model_name);
- bss->model_name = os_strdup(pos);
- } else if (os_strcmp(buf, "model_number") == 0) {
- if (os_strlen(pos) > 32) {
- wpa_printf(MSG_ERROR, "Line %d: Too long "
- "model_number", line);
- errors++;
- }
- os_free(bss->model_number);
- bss->model_number = os_strdup(pos);
- } else if (os_strcmp(buf, "serial_number") == 0) {
- if (os_strlen(pos) > 32) {
- wpa_printf(MSG_ERROR, "Line %d: Too long "
- "serial_number", line);
- errors++;
- }
- os_free(bss->serial_number);
- bss->serial_number = os_strdup(pos);
- } else if (os_strcmp(buf, "device_type") == 0) {
- os_free(bss->device_type);
- bss->device_type = os_strdup(pos);
- } else if (os_strcmp(buf, "config_methods") == 0) {
- os_free(bss->config_methods);
- bss->config_methods = os_strdup(pos);
- } else if (os_strcmp(buf, "os_version") == 0) {
- if (hexstr2bin(pos, bss->os_version, 4)) {
- wpa_printf(MSG_ERROR, "Line %d: invalid "
- "os_version", line);
- errors++;
- }
- } else if (os_strcmp(buf, "ap_pin") == 0) {
- os_free(bss->ap_pin);
- bss->ap_pin = os_strdup(pos);
- } else if (os_strcmp(buf, "skip_cred_build") == 0) {
- bss->skip_cred_build = atoi(pos);
- } else if (os_strcmp(buf, "extra_cred") == 0) {
- os_free(bss->extra_cred);
- bss->extra_cred =
- (u8 *) os_readfile(pos, &bss->extra_cred_len);
- if (bss->extra_cred == NULL) {
- wpa_printf(MSG_ERROR, "Line %d: could not "
- "read Credentials from '%s'",
- line, pos);
- errors++;
- }
- } else if (os_strcmp(buf, "wps_cred_processing") == 0) {
- bss->wps_cred_processing = atoi(pos);
- } else if (os_strcmp(buf, "ap_settings") == 0) {
- os_free(bss->ap_settings);
- bss->ap_settings =
- (u8 *) os_readfile(pos, &bss->ap_settings_len);
- if (bss->ap_settings == NULL) {
- wpa_printf(MSG_ERROR, "Line %d: could not "
- "read AP Settings from '%s'",
- line, pos);
- errors++;
- }
- } else if (os_strcmp(buf, "upnp_iface") == 0) {
- bss->upnp_iface = os_strdup(pos);
- } else if (os_strcmp(buf, "friendly_name") == 0) {
- os_free(bss->friendly_name);
- bss->friendly_name = os_strdup(pos);
- } else if (os_strcmp(buf, "manufacturer_url") == 0) {
- os_free(bss->manufacturer_url);
- bss->manufacturer_url = os_strdup(pos);
- } else if (os_strcmp(buf, "model_description") == 0) {
- os_free(bss->model_description);
- bss->model_description = os_strdup(pos);
- } else if (os_strcmp(buf, "model_url") == 0) {
- os_free(bss->model_url);
- bss->model_url = os_strdup(pos);
- } else if (os_strcmp(buf, "upc") == 0) {
- os_free(bss->upc);
- bss->upc = os_strdup(pos);
-#endif /* CONFIG_WPS */
- } else {
- wpa_printf(MSG_ERROR, "Line %d: unknown configuration "
- "item '%s'", line, buf);
- errors++;
- }
- }
-
- fclose(f);
-
- for (i = 0; i < conf->num_bss; i++) {
- bss = &conf->bss[i];
-
- if (bss->individual_wep_key_len == 0) {
- /* individual keys are not use; can use key idx0 for
- * broadcast keys */
- bss->broadcast_key_idx_min = 0;
- }
-
- /* Select group cipher based on the enabled pairwise cipher
- * suites */
- pairwise = 0;
- if (bss->wpa & 1)
- pairwise |= bss->wpa_pairwise;
- if (bss->wpa & 2) {
- if (bss->rsn_pairwise == 0)
- bss->rsn_pairwise = bss->wpa_pairwise;
- pairwise |= bss->rsn_pairwise;
- }
- if (pairwise & WPA_CIPHER_TKIP)
- bss->wpa_group = WPA_CIPHER_TKIP;
- else
- bss->wpa_group = WPA_CIPHER_CCMP;
-
- bss->radius->auth_server = bss->radius->auth_servers;
- bss->radius->acct_server = bss->radius->acct_servers;
-
- if (bss->wpa && bss->ieee802_1x) {
- bss->ssid.security_policy = SECURITY_WPA;
- } else if (bss->wpa) {
- bss->ssid.security_policy = SECURITY_WPA_PSK;
- } else if (bss->ieee802_1x) {
- bss->ssid.security_policy = SECURITY_IEEE_802_1X;
- bss->ssid.wep.default_len = bss->default_wep_key_len;
- } else if (bss->ssid.wep.keys_set)
- bss->ssid.security_policy = SECURITY_STATIC_WEP;
- else
- bss->ssid.security_policy = SECURITY_PLAINTEXT;
- }
-
- if (hostapd_config_check(conf))
- errors++;
-
- if (errors) {
- wpa_printf(MSG_ERROR, "%d errors found in configuration file "
- "'%s'", errors, fname);
- hostapd_config_free(conf);
- conf = NULL;
- }
-
- return conf;
-}
-
-
-int hostapd_wep_key_cmp(struct hostapd_wep_keys *a, struct hostapd_wep_keys *b)
-{
- int i;
-
- if (a->idx != b->idx || a->default_len != b->default_len)
- return 1;
- for (i = 0; i < NUM_WEP_KEYS; i++)
- if (a->len[i] != b->len[i] ||
- os_memcmp(a->key[i], b->key[i], a->len[i]) != 0)
- return 1;
- return 0;
-}
-
-
-static void hostapd_config_free_radius(struct hostapd_radius_server *servers,
- int num_servers)
-{
- int i;
-
- for (i = 0; i < num_servers; i++) {
- os_free(servers[i].shared_secret);
- }
- os_free(servers);
-}
-
-
-static void hostapd_config_free_eap_user(struct hostapd_eap_user *user)
-{
- os_free(user->identity);
- os_free(user->password);
- os_free(user);
-}
-
-
-static void hostapd_config_free_wep(struct hostapd_wep_keys *keys)
-{
- int i;
- for (i = 0; i < NUM_WEP_KEYS; i++) {
- os_free(keys->key[i]);
- keys->key[i] = NULL;
- }
-}
-
-
-static void hostapd_config_free_bss(struct hostapd_bss_config *conf)
-{
- struct hostapd_wpa_psk *psk, *prev;
- struct hostapd_eap_user *user, *prev_user;
-
- if (conf == NULL)
- return;
-
- psk = conf->ssid.wpa_psk;
- while (psk) {
- prev = psk;
- psk = psk->next;
- os_free(prev);
- }
-
- os_free(conf->ssid.wpa_passphrase);
- os_free(conf->ssid.wpa_psk_file);
-#ifdef CONFIG_FULL_DYNAMIC_VLAN
- os_free(conf->ssid.vlan_tagged_interface);
-#endif /* CONFIG_FULL_DYNAMIC_VLAN */
-
- user = conf->eap_user;
- while (user) {
- prev_user = user;
- user = user->next;
- hostapd_config_free_eap_user(prev_user);
- }
-
- os_free(conf->dump_log_name);
- os_free(conf->eap_req_id_text);
- os_free(conf->accept_mac);
- os_free(conf->deny_mac);
- os_free(conf->nas_identifier);
- hostapd_config_free_radius(conf->radius->auth_servers,
- conf->radius->num_auth_servers);
- hostapd_config_free_radius(conf->radius->acct_servers,
- conf->radius->num_acct_servers);
- os_free(conf->rsn_preauth_interfaces);
- os_free(conf->ctrl_interface);
- os_free(conf->ca_cert);
- os_free(conf->server_cert);
- os_free(conf->private_key);
- os_free(conf->private_key_passwd);
- os_free(conf->dh_file);
- os_free(conf->pac_opaque_encr_key);
- os_free(conf->eap_fast_a_id);
- os_free(conf->eap_fast_a_id_info);
- os_free(conf->eap_sim_db);
- os_free(conf->radius_server_clients);
- os_free(conf->test_socket);
- os_free(conf->radius);
- hostapd_config_free_vlan(conf);
- if (conf->ssid.dyn_vlan_keys) {
- struct hostapd_ssid *ssid = &conf->ssid;
- size_t i;
- for (i = 0; i <= ssid->max_dyn_vlan_keys; i++) {
- if (ssid->dyn_vlan_keys[i] == NULL)
- continue;
- hostapd_config_free_wep(ssid->dyn_vlan_keys[i]);
- os_free(ssid->dyn_vlan_keys[i]);
- }
- os_free(ssid->dyn_vlan_keys);
- ssid->dyn_vlan_keys = NULL;
- }
-
-#ifdef CONFIG_IEEE80211R
- {
- struct ft_remote_r0kh *r0kh, *r0kh_prev;
- struct ft_remote_r1kh *r1kh, *r1kh_prev;
-
- r0kh = conf->r0kh_list;
- conf->r0kh_list = NULL;
- while (r0kh) {
- r0kh_prev = r0kh;
- r0kh = r0kh->next;
- os_free(r0kh_prev);
- }
-
- r1kh = conf->r1kh_list;
- conf->r1kh_list = NULL;
- while (r1kh) {
- r1kh_prev = r1kh;
- r1kh = r1kh->next;
- os_free(r1kh_prev);
- }
- }
-#endif /* CONFIG_IEEE80211R */
-
-#ifdef CONFIG_WPS
- os_free(conf->wps_pin_requests);
- os_free(conf->device_name);
- os_free(conf->manufacturer);
- os_free(conf->model_name);
- os_free(conf->model_number);
- os_free(conf->serial_number);
- os_free(conf->device_type);
- os_free(conf->config_methods);
- os_free(conf->ap_pin);
- os_free(conf->extra_cred);
- os_free(conf->ap_settings);
- os_free(conf->upnp_iface);
- os_free(conf->friendly_name);
- os_free(conf->manufacturer_url);
- os_free(conf->model_description);
- os_free(conf->model_url);
- os_free(conf->upc);
-#endif /* CONFIG_WPS */
-}
-
-
-/**
- * hostapd_config_free - Free hostapd configuration
- * @conf: Configuration data from hostapd_config_read().
- */
-void hostapd_config_free(struct hostapd_config *conf)
-{
- size_t i;
-
- if (conf == NULL)
- return;
-
- for (i = 0; i < conf->num_bss; i++)
- hostapd_config_free_bss(&conf->bss[i]);
- os_free(conf->bss);
- os_free(conf->supported_rates);
- os_free(conf->basic_rates);
-
- os_free(conf);
-}
-
-
-/**
- * hostapd_maclist_found - Find a MAC address from a list
- * @list: MAC address list
- * @num_entries: Number of addresses in the list
- * @addr: Address to search for
- * @vlan_id: Buffer for returning VLAN ID or %NULL if not needed
- * Returns: 1 if address is in the list or 0 if not.
- *
- * Perform a binary search for given MAC address from a pre-sorted list.
- */
-int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries,
- const u8 *addr, int *vlan_id)
-{
- int start, end, middle, res;
-
- start = 0;
- end = num_entries - 1;
-
- while (start <= end) {
- middle = (start + end) / 2;
- res = os_memcmp(list[middle].addr, addr, ETH_ALEN);
- if (res == 0) {
- if (vlan_id)
- *vlan_id = list[middle].vlan_id;
- return 1;
- }
- if (res < 0)
- start = middle + 1;
- else
- end = middle - 1;
- }
-
- return 0;
-}
-
-
-int hostapd_rate_found(int *list, int rate)
-{
- int i;
-
- if (list == NULL)
- return 0;
-
- for (i = 0; list[i] >= 0; i++)
- if (list[i] == rate)
- return 1;
-
- return 0;
-}
-
-
-const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan, int vlan_id)
-{
- struct hostapd_vlan *v = vlan;
- while (v) {
- if (v->vlan_id == vlan_id || v->vlan_id == VLAN_ID_WILDCARD)
- return v->ifname;
- v = v->next;
- }
- return NULL;
-}
-
-
-const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
- const u8 *addr, const u8 *prev_psk)
-{
- struct hostapd_wpa_psk *psk;
- int next_ok = prev_psk == NULL;
-
- for (psk = conf->ssid.wpa_psk; psk != NULL; psk = psk->next) {
- if (next_ok &&
- (psk->group || os_memcmp(psk->addr, addr, ETH_ALEN) == 0))
- return psk->psk;
-
- if (psk->psk == prev_psk)
- next_ok = 1;
- }
-
- return NULL;
-}
-
-
-const struct hostapd_eap_user *
-hostapd_get_eap_user(const struct hostapd_bss_config *conf, const u8 *identity,
- size_t identity_len, int phase2)
-{
- struct hostapd_eap_user *user = conf->eap_user;
-
-#ifdef CONFIG_WPS
- if (conf->wps_state && identity_len == WSC_ID_ENROLLEE_LEN &&
- os_memcmp(identity, WSC_ID_ENROLLEE, WSC_ID_ENROLLEE_LEN) == 0) {
- static struct hostapd_eap_user wsc_enrollee;
- os_memset(&wsc_enrollee, 0, sizeof(wsc_enrollee));
- wsc_enrollee.methods[0].method = eap_server_get_type(
- "WSC", &wsc_enrollee.methods[0].vendor);
- return &wsc_enrollee;
- }
-
- if (conf->wps_state && conf->ap_pin &&
- identity_len == WSC_ID_REGISTRAR_LEN &&
- os_memcmp(identity, WSC_ID_REGISTRAR, WSC_ID_REGISTRAR_LEN) == 0) {
- static struct hostapd_eap_user wsc_registrar;
- os_memset(&wsc_registrar, 0, sizeof(wsc_registrar));
- wsc_registrar.methods[0].method = eap_server_get_type(
- "WSC", &wsc_registrar.methods[0].vendor);
- wsc_registrar.password = (u8 *) conf->ap_pin;
- wsc_registrar.password_len = os_strlen(conf->ap_pin);
- return &wsc_registrar;
- }
-#endif /* CONFIG_WPS */
-
- while (user) {
- if (!phase2 && user->identity == NULL) {
- /* Wildcard match */
- break;
- }
-
- if (user->phase2 == !!phase2 && user->wildcard_prefix &&
- identity_len >= user->identity_len &&
- os_memcmp(user->identity, identity, user->identity_len) ==
- 0) {
- /* Wildcard prefix match */
- break;
- }
-
- if (user->phase2 == !!phase2 &&
- user->identity_len == identity_len &&
- os_memcmp(user->identity, identity, identity_len) == 0)
- break;
- user = user->next;
- }
-
- return user;
-}
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
deleted file mode 100644
index 9dec7247cdd7..000000000000
--- a/hostapd/ctrl_iface.c
+++ /dev/null
@@ -1,610 +0,0 @@
-/*
- * hostapd / UNIX domain socket -based control interface
- * Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Alternatively, this software may be distributed under the terms of BSD
- * license.
- *
- * See README and COPYING for more details.
- */
-
-#include "includes.h"
-
-#ifndef CONFIG_NATIVE_WINDOWS
-
-#include <sys/un.h>
-#include <sys/stat.h>
-#include <stddef.h>
-
-#include "hostapd.h"
-#include "eloop.h"
-#include "config.h"
-#include "ieee802_1x.h"
-#include "wpa.h"
-#include "radius/radius_client.h"
-#include "ieee802_11.h"
-#include "ctrl_iface.h"
-#include "sta_info.h"
-#include "accounting.h"
-#include "wps_hostapd.h"
-
-
-struct wpa_ctrl_dst {
- struct wpa_ctrl_dst *next;
- struct sockaddr_un addr;
- socklen_t addrlen;
- int debug_level;
- int errors;
-};
-
-
-static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
- const char *buf, size_t len);
-
-
-static int hostapd_ctrl_iface_attach(struct hostapd_data *hapd,
- struct sockaddr_un *from,
- socklen_t fromlen)
-{
- struct wpa_ctrl_dst *dst;
-
- dst = os_zalloc(sizeof(*dst));
- if (dst == NULL)
- return -1;
- os_memcpy(&dst->addr, from, sizeof(struct sockaddr_un));
- dst->addrlen = fromlen;
- dst->debug_level = MSG_INFO;
- dst->next = hapd->ctrl_dst;
- hapd->ctrl_dst = dst;
- wpa_hexdump(MSG_DEBUG, "CTRL_IFACE monitor attached",
- (u8 *) from->sun_path,
- fromlen - offsetof(struct sockaddr_un, sun_path));
- return 0;
-}
-
-
-static int hostapd_ctrl_iface_detach(struct hostapd_data *hapd,
- struct sockaddr_un *from,
- socklen_t fromlen)
-{
- struct wpa_ctrl_dst *dst, *prev = NULL;
-
- dst = hapd->ctrl_dst;
- while (dst) {
- if (fromlen == dst->addrlen &&
- os_memcmp(from->sun_path, dst->addr.sun_path,
- fromlen - offsetof(struct sockaddr_un, sun_path))
- == 0) {
- if (prev == NULL)
- hapd->ctrl_dst = dst->next;
- else
- prev->next = dst->next;
- os_free(dst);
- wpa_hexdump(MSG_DEBUG, "CTRL_IFACE monitor detached",
- (u8 *) from->sun_path,
- fromlen -
- offsetof(struct sockaddr_un, sun_path));
- return 0;
- }
- prev = dst;
- dst = dst->next;
- }
- return -1;
-}
-
-
-static int hostapd_ctrl_iface_level(struct hostapd_data *hapd,
- struct sockaddr_un *from,
- socklen_t fromlen,
- char *level)
-{
- struct wpa_ctrl_dst *dst;
-
- wpa_printf(MSG_DEBUG, "CTRL_IFACE LEVEL %s", level);
-
- dst = hapd->ctrl_dst;
- while (dst) {
- if (fromlen == dst->addrlen &&
- os_memcmp(from->sun_path, dst->addr.sun_path,
- fromlen - offsetof(struct sockaddr_un, sun_path))
- == 0) {
- wpa_hexdump(MSG_DEBUG, "CTRL_IFACE changed monitor "
- "level", (u8 *) from->sun_path, fromlen -
- offsetof(struct sockaddr_un, sun_path));
- dst->debug_level = atoi(level);
- return 0;
- }
- dst = dst->next;
- }
-
- return -1;
-}
-
-
-static int hostapd_ctrl_iface_sta_mib(struct hostapd_data *hapd,
- struct sta_info *sta,
- char *buf, size_t buflen)
-{
- int len, res, ret;
-
- if (sta == NULL) {
- ret = os_snprintf(buf, buflen, "FAIL\n");
- if (ret < 0 || (size_t) ret >= buflen)
- return 0;
- return ret;
- }
-
- len = 0;
- ret = os_snprintf(buf + len, buflen - len, MACSTR "\n",
- MAC2STR(sta->addr));
- if (ret < 0 || (size_t) ret >= buflen - len)
- return len;
- len += ret;
-
- res = ieee802_11_get_mib_sta(hapd, sta, buf + len, buflen - len);
- if (res >= 0)
- len += res;
- res = wpa_get_mib_sta(sta->wpa_sm, buf + len, buflen - len);
- if (res >= 0)
- len += res;
- res = ieee802_1x_get_mib_sta(hapd, sta, buf + len, buflen - len);
- if (res >= 0)
- len += res;
-
- return len;
-}
-
-
-static int hostapd_ctrl_iface_sta_first(struct hostapd_data *hapd,
- char *buf, size_t buflen)
-{
- return hostapd_ctrl_iface_sta_mib(hapd, hapd->sta_list, buf, buflen);
-}
-
-
-static int hostapd_ctrl_iface_sta(struct hostapd_data *hapd,
- const char *txtaddr,
- char *buf, size_t buflen)
-{
- u8 addr[ETH_ALEN];
- int ret;
-
- if (hwaddr_aton(txtaddr, addr)) {
- ret = os_snprintf(buf, buflen, "FAIL\n");
- if (ret < 0 || (size_t) ret >= buflen)
- return 0;
- return ret;
- }
- return hostapd_ctrl_iface_sta_mib(hapd, ap_get_sta(hapd, addr),
- buf, buflen);
-}
-
-
-static int hostapd_ctrl_iface_sta_next(struct hostapd_data *hapd,
- const char *txtaddr,
- char *buf, size_t buflen)
-{
- u8 addr[ETH_ALEN];
- struct sta_info *sta;
- int ret;
-
- if (hwaddr_aton(txtaddr, addr) ||
- (sta = ap_get_sta(hapd, addr)) == NULL) {
- ret = os_snprintf(buf, buflen, "FAIL\n");
- if (ret < 0 || (size_t) ret >= buflen)
- return 0;
- return ret;
- }
- return hostapd_ctrl_iface_sta_mib(hapd, sta->next, buf, buflen);
-}
-
-
-static int hostapd_ctrl_iface_new_sta(struct hostapd_data *hapd,
- const char *txtaddr)
-{
- u8 addr[ETH_ALEN];
- struct sta_info *sta;
-
- wpa_printf(MSG_DEBUG, "CTRL_IFACE NEW_STA %s", txtaddr);
-
- if (hwaddr_aton(txtaddr, addr))
- return -1;
-
- sta = ap_get_sta(hapd, addr);
- if (sta)
- return 0;
-
- wpa_printf(MSG_DEBUG, "Add new STA " MACSTR " based on ctrl_iface "
- "notification", MAC2STR(addr));
- sta = ap_sta_add(hapd, addr);
- if (sta == NULL)
- return -1;
-
- hostapd_new_assoc_sta(hapd, sta, 0);
- return 0;
-}
-
-
-#ifdef CONFIG_IEEE80211W
-static int hostapd_ctrl_iface_sa_query(struct hostapd_data *hapd,
- const char *txtaddr)
-{
- u8 addr[ETH_ALEN];
- u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN];
-
- wpa_printf(MSG_DEBUG, "CTRL_IFACE SA_QUERY %s", txtaddr);
-
- if (hwaddr_aton(txtaddr, addr))
- return -1;
-
- os_get_random(trans_id, WLAN_SA_QUERY_TR_ID_LEN);
- ieee802_11_send_sa_query_req(hapd, addr, trans_id);
-
- return 0;
-}
-#endif /* CONFIG_IEEE80211W */
-
-
-#ifdef CONFIG_WPS
-static int hostapd_ctrl_iface_wps_pin(struct hostapd_data *hapd, char *txt)
-{
- char *pin = os_strchr(txt, ' ');
- char *timeout_txt;
- int timeout;
-
- if (pin == NULL)
- return -1;
- *pin++ = '\0';
-
- timeout_txt = os_strchr(pin, ' ');
- if (timeout_txt) {
- *timeout_txt++ = '\0';
- timeout = atoi(timeout_txt);
- } else
- timeout = 0;
-
- return hostapd_wps_add_pin(hapd, txt, pin, timeout);
-}
-#endif /* CONFIG_WPS */
-
-
-static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
- void *sock_ctx)
-{
- struct hostapd_data *hapd = eloop_ctx;
- char buf[256];
- int res;
- struct sockaddr_un from;
- socklen_t fromlen = sizeof(from);
- char *reply;
- const int reply_size = 4096;
- int reply_len;
-
- res = recvfrom(sock, buf, sizeof(buf) - 1, 0,
- (struct sockaddr *) &from, &fromlen);
- if (res < 0) {
- perror("recvfrom(ctrl_iface)");
- return;
- }
- buf[res] = '\0';
- wpa_hexdump_ascii(MSG_DEBUG, "RX ctrl_iface", (u8 *) buf, res);
-
- reply = os_malloc(reply_size);
- if (reply == NULL) {
- sendto(sock, "FAIL\n", 5, 0, (struct sockaddr *) &from,
- fromlen);
- return;
- }
-
- os_memcpy(reply, "OK\n", 3);
- reply_len = 3;
-
- if (os_strcmp(buf, "PING") == 0) {
- os_memcpy(reply, "PONG\n", 5);
- reply_len = 5;
- } else if (os_strcmp(buf, "MIB") == 0) {
- reply_len = ieee802_11_get_mib(hapd, reply, reply_size);
- if (reply_len >= 0) {
- res = wpa_get_mib(hapd->wpa_auth, reply + reply_len,
- reply_size - reply_len);
- if (res < 0)
- reply_len = -1;
- else
- reply_len += res;
- }
- if (reply_len >= 0) {
- res = ieee802_1x_get_mib(hapd, reply + reply_len,
- reply_size - reply_len);
- if (res < 0)
- reply_len = -1;
- else
- reply_len += res;
- }
- if (reply_len >= 0) {
- res = radius_client_get_mib(hapd->radius,
- reply + reply_len,
- reply_size - reply_len);
- if (res < 0)
- reply_len = -1;
- else
- reply_len += res;
- }
- } else if (os_strcmp(buf, "STA-FIRST") == 0) {
- reply_len = hostapd_ctrl_iface_sta_first(hapd, reply,
- reply_size);
- } else if (os_strncmp(buf, "STA ", 4) == 0) {
- reply_len = hostapd_ctrl_iface_sta(hapd, buf + 4, reply,
- reply_size);
- } else if (os_strncmp(buf, "STA-NEXT ", 9) == 0) {
- reply_len = hostapd_ctrl_iface_sta_next(hapd, buf + 9, reply,
- reply_size);
- } else if (os_strcmp(buf, "ATTACH") == 0) {
- if (hostapd_ctrl_iface_attach(hapd, &from, fromlen))
- reply_len = -1;
- } else if (os_strcmp(buf, "DETACH") == 0) {
- if (hostapd_ctrl_iface_detach(hapd, &from, fromlen))
- reply_len = -1;
- } else if (os_strncmp(buf, "LEVEL ", 6) == 0) {
- if (hostapd_ctrl_iface_level(hapd, &from, fromlen,
- buf + 6))
- reply_len = -1;
- } else if (os_strncmp(buf, "NEW_STA ", 8) == 0) {
- if (hostapd_ctrl_iface_new_sta(hapd, buf + 8))
- reply_len = -1;
-#ifdef CONFIG_IEEE80211W
- } else if (os_strncmp(buf, "SA_QUERY ", 9) == 0) {
- if (hostapd_ctrl_iface_sa_query(hapd, buf + 9))
- reply_len = -1;
-#endif /* CONFIG_IEEE80211W */
-#ifdef CONFIG_WPS
- } else if (os_strncmp(buf, "WPS_PIN ", 8) == 0) {
- if (hostapd_ctrl_iface_wps_pin(hapd, buf + 8))
- reply_len = -1;
- } else if (os_strcmp(buf, "WPS_PBC") == 0) {
- if (hostapd_wps_button_pushed(hapd))
- reply_len = -1;
-#endif /* CONFIG_WPS */
- } else {
- os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
- reply_len = 16;
- }
-
- if (reply_len < 0) {
- os_memcpy(reply, "FAIL\n", 5);
- reply_len = 5;
- }
- sendto(sock, reply, reply_len, 0, (struct sockaddr *) &from, fromlen);
- os_free(reply);
-}
-
-
-static char * hostapd_ctrl_iface_path(struct hostapd_data *hapd)
-{
- char *buf;
- size_t len;
-
- if (hapd->conf->ctrl_interface == NULL)
- return NULL;
-
- len = os_strlen(hapd->conf->ctrl_interface) +
- os_strlen(hapd->conf->iface) + 2;
- buf = os_malloc(len);
- if (buf == NULL)
- return NULL;
-
- os_snprintf(buf, len, "%s/%s",
- hapd->conf->ctrl_interface, hapd->conf->iface);
- buf[len - 1] = '\0';
- return buf;
-}
-
-
-static void hostapd_ctrl_iface_msg_cb(void *ctx, int level,
- const char *txt, size_t len)
-{
- struct hostapd_data *hapd = ctx;
- if (hapd == NULL)
- return;
- hostapd_ctrl_iface_send(hapd, level, txt, len);
-}
-
-
-int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
-{
- struct sockaddr_un addr;
- int s = -1;
- char *fname = NULL;
-
- hapd->ctrl_sock = -1;
-
- if (hapd->conf->ctrl_interface == NULL)
- return 0;
-
- if (mkdir(hapd->conf->ctrl_interface, S_IRWXU | S_IRWXG) < 0) {
- if (errno == EEXIST) {
- wpa_printf(MSG_DEBUG, "Using existing control "
- "interface directory.");
- } else {
- perror("mkdir[ctrl_interface]");
- goto fail;
- }
- }
-
- if (hapd->conf->ctrl_interface_gid_set &&
- chown(hapd->conf->ctrl_interface, 0,
- hapd->conf->ctrl_interface_gid) < 0) {
- perror("chown[ctrl_interface]");
- return -1;
- }
-
- if (os_strlen(hapd->conf->ctrl_interface) + 1 +
- os_strlen(hapd->conf->iface) >= sizeof(addr.sun_path))
- goto fail;
-
- s = socket(PF_UNIX, SOCK_DGRAM, 0);
- if (s < 0) {
- perror("socket(PF_UNIX)");
- goto fail;
- }
-
- os_memset(&addr, 0, sizeof(addr));
-#ifdef __FreeBSD__
- addr.sun_len = sizeof(addr);
-#endif /* __FreeBSD__ */
- addr.sun_family = AF_UNIX;
- fname = hostapd_ctrl_iface_path(hapd);
- if (fname == NULL)
- goto fail;
- os_strlcpy(addr.sun_path, fname, sizeof(addr.sun_path));
- if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
- wpa_printf(MSG_DEBUG, "ctrl_iface bind(PF_UNIX) failed: %s",
- strerror(errno));
- if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
- wpa_printf(MSG_DEBUG, "ctrl_iface exists, but does not"
- " allow connections - assuming it was left"
- "over from forced program termination");
- if (unlink(fname) < 0) {
- perror("unlink[ctrl_iface]");
- wpa_printf(MSG_ERROR, "Could not unlink "
- "existing ctrl_iface socket '%s'",
- fname);
- goto fail;
- }
- if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) <
- 0) {
- perror("bind(PF_UNIX)");
- goto fail;
- }
- wpa_printf(MSG_DEBUG, "Successfully replaced leftover "
- "ctrl_iface socket '%s'", fname);
- } else {
- wpa_printf(MSG_INFO, "ctrl_iface exists and seems to "
- "be in use - cannot override it");
- wpa_printf(MSG_INFO, "Delete '%s' manually if it is "
- "not used anymore", fname);
- os_free(fname);
- fname = NULL;
- goto fail;
- }
- }
-
- if (hapd->conf->ctrl_interface_gid_set &&
- chown(fname, 0, hapd->conf->ctrl_interface_gid) < 0) {
- perror("chown[ctrl_interface/ifname]");
- goto fail;
- }
-
- if (chmod(fname, S_IRWXU | S_IRWXG) < 0) {
- perror("chmod[ctrl_interface/ifname]");
- goto fail;
- }
- os_free(fname);
-
- hapd->ctrl_sock = s;
- eloop_register_read_sock(s, hostapd_ctrl_iface_receive, hapd,
- NULL);
- wpa_msg_register_cb(hostapd_ctrl_iface_msg_cb);
-
- return 0;
-
-fail:
- if (s >= 0)
- close(s);
- if (fname) {
- unlink(fname);
- os_free(fname);
- }
- return -1;
-}
-
-
-void hostapd_ctrl_iface_deinit(struct hostapd_data *hapd)
-{
- struct wpa_ctrl_dst *dst, *prev;
-
- if (hapd->ctrl_sock > -1) {
- char *fname;
- eloop_unregister_read_sock(hapd->ctrl_sock);
- close(hapd->ctrl_sock);
- hapd->ctrl_sock = -1;
- fname = hostapd_ctrl_iface_path(hapd);
- if (fname)
- unlink(fname);
- os_free(fname);
-
- if (hapd->conf->ctrl_interface &&
- rmdir(hapd->conf->ctrl_interface) < 0) {
- if (errno == ENOTEMPTY) {
- wpa_printf(MSG_DEBUG, "Control interface "
- "directory not empty - leaving it "
- "behind");
- } else {
- perror("rmdir[ctrl_interface]");
- }
- }
- }
-
- dst = hapd->ctrl_dst;
- while (dst) {
- prev = dst;
- dst = dst->next;
- os_free(prev);
- }
-}
-
-
-static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
- const char *buf, size_t len)
-{
- struct wpa_ctrl_dst *dst, *next;
- struct msghdr msg;
- int idx;
- struct iovec io[2];
- char levelstr[10];
-
- dst = hapd->ctrl_dst;
- if (hapd->ctrl_sock < 0 || dst == NULL)
- return;
-
- os_snprintf(levelstr, sizeof(levelstr), "<%d>", level);
- io[0].iov_base = levelstr;
- io[0].iov_len = os_strlen(levelstr);
- io[1].iov_base = (char *) buf;
- io[1].iov_len = len;
- os_memset(&msg, 0, sizeof(msg));
- msg.msg_iov = io;
- msg.msg_iovlen = 2;
-
- idx = 0;
- while (dst) {
- next = dst->next;
- if (level >= dst->debug_level) {
- wpa_hexdump(MSG_DEBUG, "CTRL_IFACE monitor send",
- (u8 *) dst->addr.sun_path, dst->addrlen -
- offsetof(struct sockaddr_un, sun_path));
- msg.msg_name = &dst->addr;
- msg.msg_namelen = dst->addrlen;
- if (sendmsg(hapd->ctrl_sock, &msg, 0) < 0) {
- int _errno = errno;
- wpa_printf(MSG_INFO, "CTRL_IFACE monitor[%d]: "
- "%d - %s",
- idx, errno, strerror(errno));
- dst->errors++;
- if (dst->errors > 10 || _errno == ENOENT) {
- hostapd_ctrl_iface_detach(
- hapd, &dst->addr,
- dst->addrlen);
- }
- } else
- dst->errors = 0;
- }
- idx++;
- dst = next;
- }
-}
-
-#endif /* CONFIG_NATIVE_WINDOWS */
diff --git a/hostapd/defconfig b/hostapd/defconfig
deleted file mode 100644
index 96a023d2e65d..000000000000
--- a/hostapd/defconfig
+++ /dev/null
@@ -1,144 +0,0 @@
-# Example hostapd build time configuration
-#
-# This file lists the configuration options that are used when building the
-# hostapd binary. All lines starting with # are ignored. Configuration option
-# lines must be commented out complete, if they are not to be included, i.e.,
-# just setting VARIABLE=n is not disabling that variable.
-#
-# This file is included in Makefile, so variables like CFLAGS and LIBS can also
-# be modified from here. In most cass, these lines should use += in order not
-# to override previous values of the variables.
-
-# Driver interface for Host AP driver
-CONFIG_DRIVER_HOSTAP=y
-
-# Driver interface for wired authenticator
-#CONFIG_DRIVER_WIRED=y
-
-# Driver interface for madwifi driver
-#CONFIG_DRIVER_MADWIFI=y
-#CFLAGS += -I../../madwifi # change to the madwifi source directory
-
-# Driver interface for Prism54 driver
-#CONFIG_DRIVER_PRISM54=y
-
-# Driver interface for drivers using the nl80211 kernel interface
-#CONFIG_DRIVER_NL80211=y
-# driver_nl80211.c requires a rather new libnl (version 1.1) which may not be
-# shipped with your distribution yet. If that is the case, you need to build
-# newer libnl version and point the hostapd build to use it.
-#LIBNL=/usr/src/libnl
-#CFLAGS += -I$(LIBNL)/include
-#LIBS += -L$(LIBNL)/lib
-
-# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
-#CONFIG_DRIVER_BSD=y
-#CFLAGS += -I/usr/local/include
-#LIBS += -L/usr/local/lib
-
-# Driver interface for no driver (e.g., RADIUS server only)
-#CONFIG_DRIVER_NONE=y
-
-# IEEE 802.11F/IAPP
-CONFIG_IAPP=y
-
-# WPA2/IEEE 802.11i RSN pre-authentication
-CONFIG_RSN_PREAUTH=y
-
-# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
-CONFIG_PEERKEY=y
-
-# IEEE 802.11w (management frame protection)
-# This version is an experimental implementation based on IEEE 802.11w/D1.0
-# draft and is subject to change since the standard has not yet been finalized.
-# Driver support is also needed for IEEE 802.11w.
-#CONFIG_IEEE80211W=y
-
-# Integrated EAP server
-CONFIG_EAP=y
-
-# EAP-MD5 for the integrated EAP server
-CONFIG_EAP_MD5=y
-
-# EAP-TLS for the integrated EAP server
-CONFIG_EAP_TLS=y
-
-# EAP-MSCHAPv2 for the integrated EAP server
-CONFIG_EAP_MSCHAPV2=y
-
-# EAP-PEAP for the integrated EAP server
-CONFIG_EAP_PEAP=y
-
-# EAP-GTC for the integrated EAP server
-CONFIG_EAP_GTC=y
-
-# EAP-TTLS for the integrated EAP server
-CONFIG_EAP_TTLS=y
-
-# EAP-SIM for the integrated EAP server
-#CONFIG_EAP_SIM=y
-
-# EAP-AKA for the integrated EAP server
-#CONFIG_EAP_AKA=y
-
-# EAP-AKA' for the integrated EAP server
-# This requires CONFIG_EAP_AKA to be enabled, too.
-#CONFIG_EAP_AKA_PRIME=y
-
-# EAP-PAX for the integrated EAP server
-#CONFIG_EAP_PAX=y
-
-# EAP-PSK for the integrated EAP server (this is _not_ needed for WPA-PSK)
-#CONFIG_EAP_PSK=y
-
-# EAP-SAKE for the integrated EAP server
-#CONFIG_EAP_SAKE=y
-
-# EAP-GPSK for the integrated EAP server
-#CONFIG_EAP_GPSK=y
-# Include support for optional SHA256 cipher suite in EAP-GPSK
-#CONFIG_EAP_GPSK_SHA256=y
-
-# EAP-FAST for the integrated EAP server
-# Note: Default OpenSSL package does not include support for all the
-# functionality needed for EAP-FAST. If EAP-FAST is enabled with OpenSSL,
-# the OpenSSL library must be patched (openssl-0.9.9-session-ticket.patch)
-# to add the needed functions.
-#CONFIG_EAP_FAST=y
-
-# Wi-Fi Protected Setup (WPS)
-#CONFIG_WPS=y
-# Enable UPnP support for external WPS Registrars
-#CONFIG_WPS_UPNP=y
-
-# EAP-IKEv2
-#CONFIG_EAP_IKEV2=y
-
-# Trusted Network Connect (EAP-TNC)
-#CONFIG_EAP_TNC=y
-
-# PKCS#12 (PFX) support (used to read private key and certificate file from
-# a file that usually has extension .p12 or .pfx)
-CONFIG_PKCS12=y
-
-# RADIUS authentication server. This provides access to the integrated EAP
-# server from external hosts using RADIUS.
-#CONFIG_RADIUS_SERVER=y
-
-# Build IPv6 support for RADIUS operations
-CONFIG_IPV6=y
-
-# IEEE Std 802.11r-2008 (Fast BSS Transition)
-#CONFIG_IEEE80211R=y
-
-# Use the hostapd's IEEE 802.11 authentication (ACL), but without
-# the IEEE 802.11 Management capability (e.g., madwifi or FreeBSD/net80211)
-#CONFIG_DRIVER_RADIUS_ACL=y
-
-# IEEE 802.11n (High Throughput) support
-#CONFIG_IEEE80211N=y
-
-# Remove debugging code that is printing out debug messages to stdout.
-# This can be used to reduce the size of the hostapd considerably if debugging
-# code is not needed.
-#CONFIG_NO_STDOUT_DEBUG=y
diff --git a/hostapd/doc/code_structure.doxygen b/hostapd/doc/code_structure.doxygen
deleted file mode 100644
index fdcf725b5d7f..000000000000
--- a/hostapd/doc/code_structure.doxygen
+++ /dev/null
@@ -1,5 +0,0 @@
-/**
-\page code_structure Structure of the source code
-
-
-*/
diff --git a/hostapd/doc/ctrl_iface.doxygen b/hostapd/doc/ctrl_iface.doxygen
deleted file mode 100644
index 76cfc6a6b79c..000000000000
--- a/hostapd/doc/ctrl_iface.doxygen
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
-\page ctrl_iface_page Control interface
-
-hostapd implements a control interface that can be used by
-external programs to control the operations of the hostapd
-daemon and to get status information and event notifications. There is
-a small C library, in a form of a single C file, wpa_ctrl.c, that
-provides helper functions to facilitate the use of the control
-interface. External programs can link this file into them and then use
-the library functions documented in wpa_ctrl.h to interact with
-%wpa_supplicant. This library can also be used with C++. hostapd_cli.c
-is an example program using this library.
-
-There are multiple mechanisms for inter-process communication. For
-example, Linux version of hostapd is using UNIX domain sockets for the
-control interface. The use of the functions defined in wpa_ctrl.h can
-be used to hide the details of the used IPC from external programs.
-
-
-\section using_ctrl_iface Using the control interface
-
-External programs, e.g., a GUI or a configuration utility, that need to
-communicate with hostapd should link in wpa_ctrl.c. This
-allows them to use helper functions to open connection to the control
-interface with wpa_ctrl_open() and to send commands with
-wpa_ctrl_request().
-
-hostapd uses the control interface for two types of communication:
-commands and unsolicited event messages. Commands are a pair of
-messages, a request from the external program and a response from
-hostapd. These can be executed using wpa_ctrl_request().
-Unsolicited event messages are sent by hostapd to the control
-interface connection without specific request from the external program
-for receiving each message. However, the external program needs to
-attach to the control interface with wpa_ctrl_attach() to receive these
-unsolicited messages.
-
-If the control interface connection is used both for commands and
-unsolicited event messages, there is potential for receiving an
-unsolicited message between the command request and response.
-wpa_ctrl_request() caller will need to supply a callback, msg_cb,
-for processing these messages. Often it is easier to open two
-control interface connections by calling wpa_ctrl_open() twice and
-then use one of the connections for commands and the other one for
-unsolicited messages. This way command request/response pairs will
-not be broken by unsolicited messages. wpa_cli is an example of how
-to use only one connection for both purposes and wpa_gui demonstrates
-how to use two separate connections.
-
-Once the control interface connection is not needed anymore, it should
-be closed by calling wpa_ctrl_close(). If the connection was used for
-unsolicited event messages, it should be first detached by calling
-wpa_ctrl_detach().
-
-
-\section ctrl_iface_cmds Control interface commands
-
-Following commands can be used with wpa_ctrl_request():
-
-\subsection ctrl_iface_PING PING
-
-This command can be used to test whether hostapd is replying
-to the control interface commands. The expected reply is \c PONG if the
-connection is open and hostapd is processing commands.
-
-*/
diff --git a/hostapd/doc/doxygen.fast b/hostapd/doc/doxygen.fast
deleted file mode 100644
index 650c73d817f4..000000000000
--- a/hostapd/doc/doxygen.fast
+++ /dev/null
@@ -1,238 +0,0 @@
-# Doxyfile 1.4.4
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-PROJECT_NAME = hostapd
-PROJECT_NUMBER = 0.6.x
-OUTPUT_DIRECTORY = hostapd/doc
-CREATE_SUBDIRS = NO
-OUTPUT_LANGUAGE = English
-BRIEF_MEMBER_DESC = YES
-REPEAT_BRIEF = YES
-ABBREVIATE_BRIEF = "The $name class" \
- "The $name widget" \
- "The $name file" \
- is \
- provides \
- specifies \
- contains \
- represents \
- a \
- an \
- the
-ALWAYS_DETAILED_SEC = NO
-INLINE_INHERITED_MEMB = NO
-FULL_PATH_NAMES = YES
-STRIP_FROM_PATH =
-STRIP_FROM_INC_PATH =
-SHORT_NAMES = NO
-JAVADOC_AUTOBRIEF = NO
-MULTILINE_CPP_IS_BRIEF = NO
-DETAILS_AT_TOP = NO
-INHERIT_DOCS = YES
-DISTRIBUTE_GROUP_DOC = NO
-SEPARATE_MEMBER_PAGES = NO
-TAB_SIZE = 8
-ALIASES =
-OPTIMIZE_OUTPUT_FOR_C = YES
-OPTIMIZE_OUTPUT_JAVA = NO
-SUBGROUPING = YES
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-EXTRACT_ALL = NO
-EXTRACT_PRIVATE = NO
-EXTRACT_STATIC = NO
-EXTRACT_LOCAL_CLASSES = YES
-EXTRACT_LOCAL_METHODS = NO
-HIDE_UNDOC_MEMBERS = NO
-HIDE_UNDOC_CLASSES = NO
-HIDE_FRIEND_COMPOUNDS = NO
-HIDE_IN_BODY_DOCS = NO
-INTERNAL_DOCS = NO
-CASE_SENSE_NAMES = YES
-HIDE_SCOPE_NAMES = NO
-SHOW_INCLUDE_FILES = YES
-INLINE_INFO = YES
-SORT_MEMBER_DOCS = YES
-SORT_BRIEF_DOCS = NO
-SORT_BY_SCOPE_NAME = NO
-GENERATE_TODOLIST = YES
-GENERATE_TESTLIST = YES
-GENERATE_BUGLIST = YES
-GENERATE_DEPRECATEDLIST= YES
-ENABLED_SECTIONS =
-MAX_INITIALIZER_LINES = 30
-SHOW_USED_FILES = YES
-SHOW_DIRECTORIES = YES
-FILE_VERSION_FILTER =
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-QUIET = NO
-WARNINGS = YES
-WARN_IF_UNDOCUMENTED = NO
-WARN_IF_DOC_ERROR = YES
-WARN_NO_PARAMDOC = YES
-WARN_FORMAT = "$file:$line: $text"
-WARN_LOGFILE =
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-INPUT = hostapd \
- src/common \
- src/crypto \
- src/eap_common \
- src/eap_server \
- src/l2_packet \
- src/radius \
- src/rsn_supp \
- src/tls \
- src/utils \
- src/wps
-FILE_PATTERNS = *.c *.h *.doxygen
-RECURSIVE = YES
-EXCLUDE =
-EXCLUDE_SYMLINKS = NO
-EXCLUDE_PATTERNS =
-EXAMPLE_PATH =
-EXAMPLE_PATTERNS = *
-EXAMPLE_RECURSIVE = NO
-IMAGE_PATH = hostapd/doc
-INPUT_FILTER = kerneldoc2doxygen.pl
-FILTER_PATTERNS =
-FILTER_SOURCE_FILES = YES
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-SOURCE_BROWSER = YES
-INLINE_SOURCES = NO
-STRIP_CODE_COMMENTS = YES
-REFERENCED_BY_RELATION = NO
-REFERENCES_RELATION = NO
-VERBATIM_HEADERS = NO
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-ALPHABETICAL_INDEX = YES
-COLS_IN_ALPHA_INDEX = 3
-IGNORE_PREFIX =
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-GENERATE_HTML = YES
-HTML_OUTPUT = html
-HTML_FILE_EXTENSION = .html
-HTML_HEADER =
-HTML_FOOTER =
-HTML_STYLESHEET =
-HTML_ALIGN_MEMBERS = YES
-GENERATE_HTMLHELP = NO
-CHM_FILE =
-HHC_LOCATION =
-GENERATE_CHI = NO
-BINARY_TOC = NO
-TOC_EXPAND = NO
-DISABLE_INDEX = NO
-ENUM_VALUES_PER_LINE = 4
-GENERATE_TREEVIEW = NO
-TREEVIEW_WIDTH = 250
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-GENERATE_LATEX = NO
-LATEX_OUTPUT = latex
-LATEX_CMD_NAME = latex
-MAKEINDEX_CMD_NAME = makeindex
-COMPACT_LATEX = NO
-PAPER_TYPE = a4wide
-EXTRA_PACKAGES =
-LATEX_HEADER =
-PDF_HYPERLINKS = YES
-USE_PDFLATEX = YES
-LATEX_BATCHMODE = NO
-LATEX_HIDE_INDICES = NO
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-GENERATE_RTF = NO
-RTF_OUTPUT = rtf
-COMPACT_RTF = NO
-RTF_HYPERLINKS = NO
-RTF_STYLESHEET_FILE =
-RTF_EXTENSIONS_FILE =
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-GENERATE_MAN = NO
-MAN_OUTPUT = man
-MAN_EXTENSION = .3
-MAN_LINKS = NO
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-GENERATE_XML = NO
-XML_OUTPUT = xml
-XML_SCHEMA =
-XML_DTD =
-XML_PROGRAMLISTING = YES
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-GENERATE_AUTOGEN_DEF = NO
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-GENERATE_PERLMOD = NO
-PERLMOD_LATEX = NO
-PERLMOD_PRETTY = YES
-PERLMOD_MAKEVAR_PREFIX =
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor
-#---------------------------------------------------------------------------
-ENABLE_PREPROCESSING = YES
-MACRO_EXPANSION = NO
-EXPAND_ONLY_PREDEF = NO
-SEARCH_INCLUDES = YES
-INCLUDE_PATH =
-INCLUDE_FILE_PATTERNS =
-PREDEFINED = RADIUS_SERVER EAP_SERVER EAP_SIM
-EXPAND_AS_DEFINED =
-SKIP_FUNCTION_MACROS = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references
-#---------------------------------------------------------------------------
-TAGFILES =
-GENERATE_TAGFILE =
-ALLEXTERNALS = NO
-EXTERNAL_GROUPS = YES
-PERL_PATH = /usr/bin/perl
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool
-#---------------------------------------------------------------------------
-CLASS_DIAGRAMS = NO
-HIDE_UNDOC_RELATIONS = YES
-HAVE_DOT = NO
-CLASS_GRAPH = YES
-COLLABORATION_GRAPH = YES
-GROUP_GRAPHS = YES
-UML_LOOK = NO
-TEMPLATE_RELATIONS = NO
-INCLUDE_GRAPH = YES
-INCLUDED_BY_GRAPH = YES
-CALL_GRAPH = YES
-GRAPHICAL_HIERARCHY = YES
-DIRECTORY_GRAPH = NO
-DOT_IMAGE_FORMAT = png
-DOT_PATH =
-DOTFILE_DIRS =
-MAX_DOT_GRAPH_DEPTH = 1000
-DOT_TRANSPARENT = NO
-DOT_MULTI_TARGETS = NO
-GENERATE_LEGEND = YES
-DOT_CLEANUP = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to the search engine
-#---------------------------------------------------------------------------
-SEARCHENGINE = NO
diff --git a/hostapd/doc/doxygen.full b/hostapd/doc/doxygen.full
deleted file mode 100644
index f8c49bff7074..000000000000
--- a/hostapd/doc/doxygen.full
+++ /dev/null
@@ -1,238 +0,0 @@
-# Doxyfile 1.4.4
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-PROJECT_NAME = hostapd
-PROJECT_NUMBER = 0.6.x
-OUTPUT_DIRECTORY = hostapd/doc
-CREATE_SUBDIRS = NO
-OUTPUT_LANGUAGE = English
-BRIEF_MEMBER_DESC = YES
-REPEAT_BRIEF = YES
-ABBREVIATE_BRIEF = "The $name class" \
- "The $name widget" \
- "The $name file" \
- is \
- provides \
- specifies \
- contains \
- represents \
- a \
- an \
- the
-ALWAYS_DETAILED_SEC = NO
-INLINE_INHERITED_MEMB = NO
-FULL_PATH_NAMES = YES
-STRIP_FROM_PATH =
-STRIP_FROM_INC_PATH =
-SHORT_NAMES = NO
-JAVADOC_AUTOBRIEF = NO
-MULTILINE_CPP_IS_BRIEF = NO
-DETAILS_AT_TOP = NO
-INHERIT_DOCS = YES
-DISTRIBUTE_GROUP_DOC = NO
-SEPARATE_MEMBER_PAGES = NO
-TAB_SIZE = 8
-ALIASES =
-OPTIMIZE_OUTPUT_FOR_C = YES
-OPTIMIZE_OUTPUT_JAVA = NO
-SUBGROUPING = YES
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-EXTRACT_ALL = NO
-EXTRACT_PRIVATE = NO
-EXTRACT_STATIC = NO
-EXTRACT_LOCAL_CLASSES = YES
-EXTRACT_LOCAL_METHODS = NO
-HIDE_UNDOC_MEMBERS = NO
-HIDE_UNDOC_CLASSES = NO
-HIDE_FRIEND_COMPOUNDS = NO
-HIDE_IN_BODY_DOCS = NO
-INTERNAL_DOCS = NO
-CASE_SENSE_NAMES = YES
-HIDE_SCOPE_NAMES = NO
-SHOW_INCLUDE_FILES = YES
-INLINE_INFO = YES
-SORT_MEMBER_DOCS = YES
-SORT_BRIEF_DOCS = NO
-SORT_BY_SCOPE_NAME = NO
-GENERATE_TODOLIST = YES
-GENERATE_TESTLIST = YES
-GENERATE_BUGLIST = YES
-GENERATE_DEPRECATEDLIST= YES
-ENABLED_SECTIONS =
-MAX_INITIALIZER_LINES = 30
-SHOW_USED_FILES = YES
-SHOW_DIRECTORIES = YES
-FILE_VERSION_FILTER =
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-QUIET = NO
-WARNINGS = YES
-WARN_IF_UNDOCUMENTED = NO
-WARN_IF_DOC_ERROR = YES
-WARN_NO_PARAMDOC = YES
-WARN_FORMAT = "$file:$line: $text"
-WARN_LOGFILE =
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-INPUT = hostapd \
- src/common \
- src/crypto \
- src/eap_common \
- src/eap_server \
- src/l2_packet \
- src/radius \
- src/rsn_supp \
- src/tls \
- src/utils \
- src/wps
-FILE_PATTERNS = *.c *.h *.doxygen
-RECURSIVE = YES
-EXCLUDE =
-EXCLUDE_SYMLINKS = NO
-EXCLUDE_PATTERNS =
-EXAMPLE_PATH =
-EXAMPLE_PATTERNS = *
-EXAMPLE_RECURSIVE = NO
-IMAGE_PATH = hostapd/doc
-INPUT_FILTER = kerneldoc2doxygen.pl
-FILTER_PATTERNS =
-FILTER_SOURCE_FILES = YES
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-SOURCE_BROWSER = YES
-INLINE_SOURCES = NO
-STRIP_CODE_COMMENTS = YES
-REFERENCED_BY_RELATION = NO
-REFERENCES_RELATION = NO
-VERBATIM_HEADERS = NO
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-ALPHABETICAL_INDEX = YES
-COLS_IN_ALPHA_INDEX = 3
-IGNORE_PREFIX =
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-GENERATE_HTML = YES
-HTML_OUTPUT = html
-HTML_FILE_EXTENSION = .html
-HTML_HEADER =
-HTML_FOOTER =
-HTML_STYLESHEET =
-HTML_ALIGN_MEMBERS = YES
-GENERATE_HTMLHELP = NO
-CHM_FILE =
-HHC_LOCATION =
-GENERATE_CHI = NO
-BINARY_TOC = NO
-TOC_EXPAND = NO
-DISABLE_INDEX = NO
-ENUM_VALUES_PER_LINE = 4
-GENERATE_TREEVIEW = NO
-TREEVIEW_WIDTH = 250
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-GENERATE_LATEX = YES
-LATEX_OUTPUT = latex
-LATEX_CMD_NAME = latex
-MAKEINDEX_CMD_NAME = makeindex
-COMPACT_LATEX = NO
-PAPER_TYPE = a4wide
-EXTRA_PACKAGES =
-LATEX_HEADER =
-PDF_HYPERLINKS = YES
-USE_PDFLATEX = YES
-LATEX_BATCHMODE = NO
-LATEX_HIDE_INDICES = NO
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-GENERATE_RTF = NO
-RTF_OUTPUT = rtf
-COMPACT_RTF = NO
-RTF_HYPERLINKS = NO
-RTF_STYLESHEET_FILE =
-RTF_EXTENSIONS_FILE =
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-GENERATE_MAN = NO
-MAN_OUTPUT = man
-MAN_EXTENSION = .3
-MAN_LINKS = NO
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-GENERATE_XML = NO
-XML_OUTPUT = xml
-XML_SCHEMA =
-XML_DTD =
-XML_PROGRAMLISTING = YES
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-GENERATE_AUTOGEN_DEF = NO
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-GENERATE_PERLMOD = NO
-PERLMOD_LATEX = NO
-PERLMOD_PRETTY = YES
-PERLMOD_MAKEVAR_PREFIX =
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor
-#---------------------------------------------------------------------------
-ENABLE_PREPROCESSING = YES
-MACRO_EXPANSION = NO
-EXPAND_ONLY_PREDEF = NO
-SEARCH_INCLUDES = YES
-INCLUDE_PATH =
-INCLUDE_FILE_PATTERNS =
-PREDEFINED = RADIUS_SERVER EAP_SERVER EAP_SIM
-EXPAND_AS_DEFINED =
-SKIP_FUNCTION_MACROS = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references
-#---------------------------------------------------------------------------
-TAGFILES =
-GENERATE_TAGFILE =
-ALLEXTERNALS = NO
-EXTERNAL_GROUPS = YES
-PERL_PATH = /usr/bin/perl
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool
-#---------------------------------------------------------------------------
-CLASS_DIAGRAMS = NO
-HIDE_UNDOC_RELATIONS = YES
-HAVE_DOT = YES
-CLASS_GRAPH = YES
-COLLABORATION_GRAPH = YES
-GROUP_GRAPHS = YES
-UML_LOOK = NO
-TEMPLATE_RELATIONS = NO
-INCLUDE_GRAPH = YES
-INCLUDED_BY_GRAPH = YES
-CALL_GRAPH = YES
-GRAPHICAL_HIERARCHY = YES
-DIRECTORY_GRAPH = NO
-DOT_IMAGE_FORMAT = png
-DOT_PATH =
-DOTFILE_DIRS =
-MAX_DOT_GRAPH_DEPTH = 1000
-DOT_TRANSPARENT = NO
-DOT_MULTI_TARGETS = NO
-GENERATE_LEGEND = YES
-DOT_CLEANUP = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to the search engine
-#---------------------------------------------------------------------------
-SEARCHENGINE = YES
diff --git a/hostapd/doc/driver_wrapper.doxygen b/hostapd/doc/driver_wrapper.doxygen
deleted file mode 100644
index 0ad196f2d6b6..000000000000
--- a/hostapd/doc/driver_wrapper.doxygen
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
-\page driver_wrapper Driver wrapper implementation (driver.h, drivers.c)
-
-All hardware and driver dependent functionality is in separate C files
-that implement defined wrapper functions. Other parts
-of the hostapd are designed to be hardware, driver, and operating
-system independent.
-
-Driver wrappers need to implement whatever calls are used in the
-target operating system/driver for controlling wireless LAN
-devices. As an example, in case of Linux, these are mostly some glue
-code and ioctl() calls and netlink message parsing for Linux Wireless
-Extensions (WE). Since features required for WPA were added only recently to
-Linux Wireless Extensions (in version 18), some driver specific code is used
-in number of driver interface implementations. These driver dependent parts
-can be replaced with generic code in driver_wext.c once the target driver
-includes full support for WE-18. After that, all Linux drivers, at
-least in theory, could use the same driver wrapper code.
-
-*/
diff --git a/hostapd/doc/eap.doxygen b/hostapd/doc/eap.doxygen
deleted file mode 100644
index f0f135aa9598..000000000000
--- a/hostapd/doc/eap.doxygen
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
-\page eap_module EAP server implementation
-
-Extensible Authentication Protocol (EAP) is an authentication framework
-defined in RFC 3748. hostapd uses a separate code module for EAP server
-implementation. This module was designed to use only a minimal set of
-direct function calls (mainly, to debug/event functions) in order for
-it to be usable in other programs. The design of the EAP
-implementation is based loosely on RFC 4137. The state machine is
-defined in this RFC and so is the interface between the server state
-machine and methods. As such, this RFC provides useful information for
-understanding the EAP server implementation in hostapd.
-
-Some of the terminology used in EAP state machine is referring to
-EAPOL (IEEE 802.1X), but there is no strict requirement on the lower
-layer being IEEE 802.1X if EAP module is built for other programs than
-%wpa_supplicant. These terms should be understood to refer to the
-lower layer as defined in RFC 4137.
-
-
-\section adding_eap_methods Adding EAP methods
-
-Each EAP method is implemented as a separate module, usually as one C
-file named eap_<name of the method>.c, e.g., eap_md5.c. All EAP
-methods use the same interface between the server state machine and
-method specific functions. This allows new EAP methods to be added
-without modifying the core EAP state machine implementation.
-
-New EAP methods need to be registered by adding them into the build
-(Makefile) and the EAP method registration list in the
-eap_server_register_methods() function of eap_methods.c. Each EAP
-method should use a build-time configuration option, e.g., EAP_TLS, in
-order to make it possible to select which of the methods are included
-in the build.
-
-EAP methods must implement the interface defined in eap_i.h. struct
-eap_method defines the needed function pointers that each EAP method
-must provide. In addition, the EAP type and name are registered using
-this structure. This interface is based on section 4.4 of RFC 4137.
-
-It is recommended that the EAP methods would use generic helper
-functions, eap_msg_alloc() and eap_hdr_validate() when processing
-messages. This allows code sharing and can avoid missing some of the
-needed validation steps for received packets. In addition, these
-functions make it easier to change between expanded and legacy EAP
-header, if needed.
-
-When adding an EAP method that uses a vendor specific EAP type
-(Expanded Type as defined in RFC 3748, Chapter 5.7), the new method
-must be registered by passing vendor id instead of EAP_VENDOR_IETF to
-eap_server_method_alloc(). These methods must not try to emulate
-expanded types by registering a legacy EAP method for type 254. See
-eap_vendor_test.c for an example of an EAP method implementation that
-is implemented as an expanded type.
-
-*/
diff --git a/hostapd/doc/hostapd.fig b/hostapd/doc/hostapd.fig
deleted file mode 100644
index af3f0be19a9b..000000000000
--- a/hostapd/doc/hostapd.fig
+++ /dev/null
@@ -1,264 +0,0 @@
-#FIG 3.2
-Landscape
-Center
-Inches
-Letter
-100.00
-Single
--2
-1200 2
-6 1875 4050 2925 4350
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 1875 4050 2925 4050 2925 4350 1875 4350 1875 4050
-4 0 0 50 -1 0 12 0.0000 4 180 735 2025 4275 l2_packet\001
--6
-6 4725 1200 5925 1500
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 4725 1200 5925 1200 5925 1500 4725 1500 4725 1200
-4 0 0 50 -1 0 12 0.0000 4 135 1005 4800 1425 GUI frontend\001
--6
-6 6000 2700 7200 3225
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 6000 2700 7200 2700 7200 3225 6000 3225 6000 2700
-4 0 0 50 -1 0 12 0.0000 4 135 975 6075 2925 WPA/WPA2\001
-4 0 0 50 -1 0 12 0.0000 4 135 1065 6075 3150 state machine\001
--6
-6 6000 4950 7200 5475
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 6000 4950 7200 4950 7200 5475 6000 5475 6000 4950
-4 0 0 50 -1 0 12 0.0000 4 135 360 6075 5175 EAP\001
-4 0 0 50 -1 0 12 0.0000 4 135 1065 6075 5400 state machine\001
--6
-6 4350 3900 5025 4425
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 4350 3900 5025 3900 5025 4425 4350 4425 4350 3900
-4 0 0 50 -1 0 12 0.0000 4 105 420 4500 4125 event\001
-4 0 0 50 -1 0 12 0.0000 4 180 315 4500 4350 loop\001
--6
-6 4275 2550 5100 2850
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 4275 2550 5100 2550 5100 2850 4275 2850 4275 2550
-4 0 0 50 -1 0 12 0.0000 4 135 450 4425 2775 ctrl i/f\001
--6
-6 6000 3900 7200 4425
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 6000 3900 7200 3900 7200 4425 6000 4425 6000 3900
-4 0 0 50 -1 0 12 0.0000 4 135 600 6075 4125 EAPOL\001
-4 0 0 50 -1 0 12 0.0000 4 135 1065 6075 4350 state machine\001
--6
-6 2775 3150 4050 3450
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 2775 3150 4050 3150 4050 3450 2775 3450 2775 3150
-4 0 0 50 -1 0 12 0.0000 4 180 990 2925 3375 configuration\001
--6
-6 3450 1200 4575 1500
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 3450 1200 4575 1200 4575 1500 3450 1500 3450 1200
-4 0 0 50 -1 0 12 0.0000 4 180 870 3600 1425 hostapd_cli\001
--6
-6 3525 7800 5775 8100
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 3525 7800 5775 7800 5775 8100 3525 8100 3525 7800
-4 0 0 50 -1 0 12 0.0000 4 135 2145 3600 8025 kernel network device driver\001
--6
-6 4275 6000 5100 6300
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 4275 6000 5100 6000 5100 6300 4275 6300 4275 6000
-4 0 0 50 -1 0 12 0.0000 4 135 630 4350 6225 driver i/f\001
--6
-6 8175 4725 9225 5025
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 8175 4725 9225 4725 9225 5025 8175 5025 8175 4725
-4 0 0 50 -1 0 12 0.0000 4 135 735 8250 4950 EAP-TLS\001
--6
-6 9300 4725 10350 5025
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 9300 4725 10350 4725 10350 5025 9300 5025 9300 4725
-4 0 0 50 -1 0 12 0.0000 4 135 810 9375 4950 EAP-MD5\001
--6
-6 8175 5100 9225 5400
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 8175 5100 9225 5100 9225 5400 8175 5400 8175 5100
-4 0 0 50 -1 0 12 0.0000 4 135 885 8250 5325 EAP-PEAP\001
--6
-6 9300 5100 10350 5400
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 9300 5100 10350 5100 10350 5400 9300 5400 9300 5100
-4 0 0 50 -1 0 12 0.0000 4 135 840 9375 5325 EAP-TTLS\001
--6
-6 8175 5475 9225 5775
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 8175 5475 9225 5475 9225 5775 8175 5775 8175 5475
-4 0 0 50 -1 0 12 0.0000 4 135 780 8250 5700 EAP-GTC\001
--6
-6 8175 5850 9225 6150
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 8175 5850 9225 5850 9225 6150 8175 6150 8175 5850
-4 0 0 50 -1 0 12 0.0000 4 135 750 8250 6075 EAP-SIM\001
--6
-6 8175 6225 9225 6525
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 8175 6225 9225 6225 9225 6525 8175 6525 8175 6225
-4 0 0 50 -1 0 12 0.0000 4 135 765 8250 6450 EAP-PSK\001
--6
-6 9300 5850 10350 6150
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 9300 5850 10350 5850 10350 6150 9300 6150 9300 5850
-4 0 0 50 -1 0 12 0.0000 4 135 825 9375 6075 EAP-AKA\001
--6
-6 9300 5475 10350 5775
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 9300 5475 10350 5475 10350 5775 9300 5775 9300 5475
-4 0 0 50 -1 0 12 0.0000 4 135 795 9375 5700 EAP-PAX\001
--6
-6 8175 6600 9675 6900
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 8175 6600 9675 6600 9675 6900 8175 6900 8175 6600
-4 0 0 50 -1 0 12 0.0000 4 135 1365 8250 6825 EAP-MSCHAPv2\001
--6
-6 8700 3450 9375 3750
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 8700 3450 9375 3450 9375 3750 8700 3750 8700 3450
-4 0 0 50 -1 0 12 0.0000 4 150 480 8775 3675 crypto\001
--6
-6 9600 3450 10275 3750
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 9600 3450 10275 3450 10275 3750 9600 3750 9600 3450
-4 0 0 50 -1 0 12 0.0000 4 135 315 9750 3675 TLS\001
--6
-6 6000 5775 7200 6300
-6 6000 5775 7200 6300
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 6000 5775 7200 5775 7200 6300 6000 6300 6000 5775
-4 0 0 50 -1 0 12 0.0000 4 135 690 6075 6000 RADIUS\001
--6
-4 0 0 50 -1 0 12 0.0000 4 90 480 6075 6225 server\001
--6
-6 8100 2250 8925 2775
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 8100 2250 8925 2250 8925 2775 8100 2775 8100 2250
-4 0 0 50 -1 0 12 0.0000 4 135 690 8175 2475 RADIUS\001
-4 0 0 50 -1 0 12 0.0000 4 135 420 8175 2700 client\001
--6
-6 3150 5475 4425 5775
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 3150 5475 4425 5475 4425 5775 3150 5775 3150 5475
-4 0 0 50 -1 0 12 0.0000 4 135 990 3300 5700 driver events\001
--6
-6 1950 5550 2625 6075
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 1950 5550 2625 5550 2625 6075 1950 6075 1950 5550
-4 0 0 50 -1 0 12 0.0000 4 135 540 2025 5775 Station\001
-4 0 0 50 -1 0 12 0.0000 4 135 375 2025 6000 table\001
--6
-6 1875 4725 2925 5250
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 1875 4725 2925 4725 2925 5250 1875 5250 1875 4725
-4 0 0 50 -1 0 12 0.0000 4 135 960 1950 4950 IEEE 802.11\001
-4 0 0 50 -1 0 12 0.0000 4 135 555 1950 5175 MLME\001
--6
-2 1 1 1 0 7 50 -1 -1 3.000 0 0 -1 0 0 2
- 1275 4200 1875 4200
-2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2
- 4500 2550 3900 1500
-2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2
- 4800 2550 5400 1500
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 2925 4200 4350 4200
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 5025 3900 6000 3000
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 5025 4200 6000 4200
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 4650 6000 4650 4425
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 6600 4425 6600 4950
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 6600 3225 6600 3900
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 7200 5250 8100 5250
-2 1 0 1 2 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 9075 4425 9075 3750
-2 1 0 1 2 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 7200 3000 8700 3525
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 4650 3900 4650 2850
-2 1 0 1 2 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 7200 4125 8700 3675
-2 1 0 1 2 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 6000 4350 5025 6000
-2 1 0 1 2 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 6000 3150 4875 6000
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 1500 2100 10800 2100 10800 7500 1500 7500 1500 2100
-2 1 0 1 2 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 9900 4425 9900 3750
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 1
- 4350 3900
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 4350 3900 4050 3450
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 4350 4425 4050 5475
-2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2
- 2250 7200 4200 7800
-2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2
- 7200 7200 5100 7800
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 2775 6900 3675 6900 3675 7200 2775 7200 2775 6900
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 3750 6900 4650 6900 4650 7200 3750 7200 3750 6900
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 4
- 2250 6900 2250 6600 7200 6600 7200 6900
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 3225 6900 3225 6600
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 4200 6900 4200 6600
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 5175 6900 5175 6600
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 6150 6900 6150 6600
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 4650 6600 4650 6300
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 1800 6900 2700 6900 2700 7200 1800 7200 1800 6900
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 4725 6900 5625 6900 5625 7200 4725 7200 4725 6900
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 5700 6900 6600 6900 6600 7200 5700 7200 5700 6900
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 6675 6900 7800 6900 7800 7200 6675 7200 6675 6900
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 8100 6975 10425 6975 10425 4425 8100 4425 8100 6975
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 6600 5475 6600 5775
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 5025 4425 6000 5775
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
- 4800 3900 5925 2550 8100 2550
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 7200 3900 8475 2775
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 9450 2250 10425 2250 10425 2775 9450 2775 9450 2250
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 8925 2475 9450 2475
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 2325 5550 2325 5250
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 2925 4950 4350 4275
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
- 2850 4725 5775 2400 8100 2400
-4 0 0 50 -1 0 12 0.0000 4 135 915 375 3975 EAPOL and\001
-4 0 0 50 -1 0 12 0.0000 4 180 630 375 4200 pre-auth\001
-4 0 0 50 -1 0 12 0.0000 4 180 810 375 4425 ethertypes\001
-4 0 0 50 -1 0 12 0.0000 4 135 1050 375 4650 from/to kernel\001
-4 0 0 50 -1 0 12 0.0000 4 135 1920 3675 1875 frontend control interface\001
-4 0 0 50 -1 2 14 0.0000 4 195 720 1637 2371 hostapd\001
-4 0 0 50 -1 0 12 0.0000 4 180 600 3825 7125 prism54\001
-4 0 0 50 -1 0 12 0.0000 4 180 510 1875 7125 hostap\001
-4 0 0 50 -1 0 12 0.0000 4 135 600 2850 7125 madwifi\001
-4 0 0 50 -1 0 12 0.0000 4 135 270 4800 7125 bsd\001
-4 0 0 50 -1 0 12 0.0000 4 105 300 6750 7125 test\001
-4 0 0 50 -1 0 12 0.0000 4 135 420 5775 7125 wired\001
-4 0 0 50 -1 0 12 0.0000 4 135 1050 8700 4650 EAP methods\001
-4 0 0 50 -1 0 12 0.0000 4 135 690 9525 2475 RADIUS\001
-4 0 0 50 -1 0 12 0.0000 4 180 825 9525 2700 accounting\001
diff --git a/hostapd/doc/kerneldoc2doxygen.pl b/hostapd/doc/kerneldoc2doxygen.pl
deleted file mode 100755
index 68835a1ddd31..000000000000
--- a/hostapd/doc/kerneldoc2doxygen.pl
+++ /dev/null
@@ -1,129 +0,0 @@
-#!/usr/bin/perl -w
-#
-##########################################################################
-# Convert kernel-doc style comments to Doxygen comments.
-##########################################################################
-#
-# This script reads a C source file from stdin, and writes
-# to stdout. Normal usage:
-#
-# $ mv file.c file.c.gtkdoc
-# $ kerneldoc2doxygen.pl <file.c.gtkdoc >file.c
-#
-# Or to do the same thing with multiple files:
-# $ perl -i.gtkdoc kerneldoc2doxygen.pl *.c *.h
-#
-# This script may also be suitable for use as a Doxygen input filter,
-# but that has not been tested.
-#
-# Back up your source files before using this script!!
-#
-##########################################################################
-# Copyright (C) 2003 Jonathan Foster <jon@jon-foster.co.uk>
-# Copyright (C) 2005 Jouni Malinen <j@w1.fi>
-# (modified for kerneldoc format used in wpa_supplicant)
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-# or look at http://www.gnu.org/licenses/gpl.html
-##########################################################################
-
-
-##########################################################################
-#
-# This function converts a single comment from gtk-doc to Doxygen format.
-# The parameter does not include the opening or closing lines
-# (i.e. given a comment like this:
-# "/**\n"
-# " * FunctionName:\n"
-# " * @foo: This describes the foo parameter\n"
-# " * @bar: This describes the bar parameter\n"
-# " * @Returns: This describes the return value\n"
-# " *\n"
-# " * This describes the function.\n"
-# " */\n"
-# This function gets:
-# " * FunctionName:\n"
-# " * @foo: This describes the foo parameter\n"
-# " * @bar: This describes the bar parameter\n"
-# " * @Returns: This describes the return value\n"
-# " *\n"
-# " * This describes the function.\n"
-# And it returns:
-# " * This describes the function.\n"
-# " *\n"
-# " * @param foo This describes the foo parameter\n"
-# " * @param bar This describes the bar parameter\n"
-# " * @return This describes the return value\n"
-# )
-#
-sub fixcomment {
- $t = $_[0];
-
- # " * func: foo" --> "\brief foo\n"
- # " * struct bar: foo" --> "\brief foo\n"
- # If this fails, not a kernel-doc comment ==> return unmodified.
- ($t =~ s/^[\t ]*\*[\t ]*(struct )?([^ \t\n]*) - ([^\n]*)/\\brief $3\n/s)
- or return $t;
-
- # " * Returns: foo" --> "\return foo"
- $t =~ s/\n[\t ]*\*[\t ]*Returns:/\n\\return/sig;
-
- # " * @foo: bar" --> "\param foo bar"
- # Handle two common typos: No ":", or "," instead of ":".
- $t =~ s/\n[\t ]*\*[\t ]*\@([^ :,]*)[:,]?[\t ]*/\n\\param $1 /sg;
-
- return $t;
-}
-
-##########################################################################
-# Start of main code
-
-# Read entire stdin into memory - one multi-line string.
-$_ = do { local $/; <> };
-
-s{^/\*\n \*}{/\*\* \\file\n\\brief};
-s{ \* Copyright}{\\par Copyright\nCopyright};
-
-# Fix any comments like "/*************" so they don't match.
-# "/***" ===> "/* *"
-s{/\*\*\*}{/\* \*}gs;
-
-# The main comment-detection code.
-s{
- ( # $1 = Open comment
- /\*\* # Open comment
- (?!\*) # Do not match /*** (redundant due to fixup above).
- [\t ]*\n? # If 1st line is whitespace, match the lot (including the newline).
- )
- (.*?) # $2 = Body of comment (multi-line)
- ( # $3 = Close comment
- ( # If possible, match the whitespace before the close-comment
- (?<=\n) # This part only matches after a newline
- [\t ]* # Eat whitespace
- )?
- \*/ # Close comment
- )
- }
- {
- $1 . fixcomment($2) . $3
- }gesx;
-# ^^^^ Modes: g - Global, match all occurances.
-# e - Evaluate the replacement as an expression.
-# s - Single-line - allows the pattern to match across newlines.
-# x - eXtended pattern, ignore embedded whitespace
-# and allow comments.
-
-# Write results to stdout
-print $_;
-
diff --git a/hostapd/doc/mainpage.doxygen b/hostapd/doc/mainpage.doxygen
deleted file mode 100644
index 7cf95de584af..000000000000
--- a/hostapd/doc/mainpage.doxygen
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
-\mainpage Developers' documentation for hostapd
-
-hostapd includes IEEE 802.11 access point management (authentication /
-association), IEEE 802.1X/WPA/WPA2 Authenticator, EAP server, and
-RADIUS authentication server functionality. It can be build with
-various configuration option, e.g., a standalone AP management
-solution or a RADIUS authentication server with support for number of
-EAP methods.
-
-The goal of this documentation and comments in the source code is to
-give enough information for other developers to understand how hostapd
-has been implemented, how it can be modified, how new drivers can be
-supported, and how hostapd can be ported to other operating
-systems. If any information is missing, feel free to contact Jouni
-Malinen <j@w1.fi> for more information. Contributions as
-patch files are also very welcome at the same address. Please note
-that hostapd is licensed under dual license, GPLv2 or BSD at user's
-choice. All contributions to hostapd are expected to use compatible
-licensing terms.
-
-The source code and read-only access to hostapd CVS repository
-is available from the project home page at
-http://hostap.epitest.fi/hostapd/. This developers' documentation
-is also available as a PDF file from
-http://hostap.epitest.fi/hostapd/hostapd-devel.pdf .
-
-The design goal for hostapd was to use hardware, driver, and
-OS independent, portable C code for all WPA functionality. The source
-code is divided into separate C files as shown on the \ref
-code_structure "code structure page". All hardware/driver specific
-functionality is in separate files that implement a \ref
-driver_wrapper "well-defined driver API". Information about porting
-to different target boards and operating systems is available on
-the \ref porting "porting page".
-
-EAPOL (IEEE 802.1X) state machines are implemented as a separate
-module that interacts with \ref eap_module "EAP server implementation".
-Similarly, RADIUS authentication server is in its own separate module.
-Both IEEE 802.1X and RADIUS authentication server can use EAP server
-functionality.
-
-hostapd implements a \ref ctrl_iface_page "control interface" that can
-be used by external programs to control the operations of the hostapdt
-daemon and to get status information and event notifications. There is
-a small C library that provides helper functions to facilitate the use
-of the control interface. This library can also be used with C++.
-
-\image html hostapd.png "hostapd modules"
-\image latex hostapd.eps "hostapd modules" width=15cm
-
-*/
diff --git a/hostapd/doc/porting.doxygen b/hostapd/doc/porting.doxygen
deleted file mode 100644
index 0621791c0be0..000000000000
--- a/hostapd/doc/porting.doxygen
+++ /dev/null
@@ -1,5 +0,0 @@
-/**
-\page porting Porting to different target boards and operating systems
-
-
-*/
diff --git a/hostapd/driver.h b/hostapd/driver.h
deleted file mode 100644
index 45f546087302..000000000000
--- a/hostapd/driver.h
+++ /dev/null
@@ -1,798 +0,0 @@
-/*
- * hostapd - driver interface definition
- * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
- * Copyright (c) 2007-2008, Intel Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Alternatively, this software may be distributed under the terms of BSD
- * license.
- *
- * See README and COPYING for more details.
- */
-
-#ifndef DRIVER_H
-#define DRIVER_H
-
-struct hostapd_sta_add_params {
- const u8 *addr;
- u16 aid;
- u16 capability;
- const u8 *supp_rates;
- size_t supp_rates_len;
- int flags;
- u16 listen_interval;
- const struct ht_cap_ie *ht_capabilities;
-};
-
-struct hostapd_freq_params {
- int mode;
- int freq;
- int ht_enabled;
- int sec_channel_offset; /* 0 = HT40 disabled, -1 = HT40 enabled,
- * secondary channel below primary, 1 = HT40
- * enabled, secondary channel above primary */
-};
-
-enum hostapd_driver_if_type {
- HOSTAPD_IF_VLAN, HOSTAPD_IF_WDS
-};
-
-struct wpa_driver_ops {
- const char *name; /* as appears in the config file */
-
- void * (*init)(struct hostapd_data *hapd);
- void * (*init_bssid)(struct hostapd_data *hapd, const u8 *bssid);
- void (*deinit)(void *priv);
-
- int (*wireless_event_init)(void *priv);
- void (*wireless_event_deinit)(void *priv);
-
- /**
- * set_8021x - enable/disable IEEE 802.1X support
- * @ifname: Interface name (for multi-SSID/VLAN support)
- * @priv: driver private data
- * @enabled: 1 = enable, 0 = disable
- *
- * Returns: 0 on success, -1 on failure
- *
- * Configure the kernel driver to enable/disable 802.1X support.
- * This may be an empty function if 802.1X support is always enabled.
- */
- int (*set_ieee8021x)(const char *ifname, void *priv, int enabled);
-
- /**
- * set_privacy - enable/disable privacy
- * @priv: driver private data
- * @enabled: 1 = privacy enabled, 0 = disabled
- *
- * Return: 0 on success, -1 on failure
- *
- * Configure privacy.
- */
- int (*set_privacy)(const char *ifname, void *priv, int enabled);
-
- int (*set_encryption)(const char *ifname, void *priv, const char *alg,
- const u8 *addr, int idx,
- const u8 *key, size_t key_len, int txkey);
- int (*get_seqnum)(const char *ifname, void *priv, const u8 *addr,
- int idx, u8 *seq);
- int (*get_seqnum_igtk)(const char *ifname, void *priv, const u8 *addr,
- int idx, u8 *seq);
- int (*flush)(void *priv);
- int (*set_generic_elem)(const char *ifname, void *priv, const u8 *elem,
- size_t elem_len);
-
- int (*read_sta_data)(void *priv, struct hostap_sta_driver_data *data,
- const u8 *addr);
- int (*send_eapol)(void *priv, const u8 *addr, const u8 *data,
- size_t data_len, int encrypt, const u8 *own_addr);
- int (*sta_deauth)(void *priv, const u8 *addr, int reason);
- int (*sta_disassoc)(void *priv, const u8 *addr, int reason);
- int (*sta_remove)(void *priv, const u8 *addr);
- int (*get_ssid)(const char *ifname, void *priv, u8 *buf, int len);
- int (*set_ssid)(const char *ifname, void *priv, const u8 *buf,
- int len);
- int (*set_countermeasures)(void *priv, int enabled);
- int (*send_mgmt_frame)(void *priv, const void *msg, size_t len,
- int flags);
- int (*set_assoc_ap)(void *priv, const u8 *addr);
- /* note: sta_add() is deprecated; use sta_add2() instead */
- int (*sta_add)(const char *ifname, void *priv, const u8 *addr, u16 aid,
- u16 capability, u8 *supp_rates, size_t supp_rates_len,
- int flags, u16 listen_interval);
- int (*sta_add2)(const char *ifname, void *priv,
- struct hostapd_sta_add_params *params);
- int (*get_inact_sec)(void *priv, const u8 *addr);
- int (*sta_clear_stats)(void *priv, const u8 *addr);
-
- /* note: set_freq() is deprecated; use set_freq2() instead */
- int (*set_freq)(void *priv, int mode, int freq);
- int (*set_freq2)(void *priv, struct hostapd_freq_params *freq);
- int (*set_rts)(void *priv, int rts);
- int (*get_rts)(void *priv, int *rts);
- int (*set_frag)(void *priv, int frag);
- int (*get_frag)(void *priv, int *frag);
- int (*set_retry)(void *priv, int short_retry, int long_retry);
- int (*get_retry)(void *priv, int *short_retry, int *long_retry);
-
- int (*sta_set_flags)(void *priv, const u8 *addr,
- int total_flags, int flags_or, int flags_and);
- int (*set_rate_sets)(void *priv, int *supp_rates, int *basic_rates,
- int mode);
- int (*set_regulatory_domain)(void *priv, unsigned int rd);
- int (*set_country)(void *priv, const char *country);
- int (*set_ieee80211d)(void *priv, int enabled);
- int (*set_beacon)(const char *ifname, void *priv,
- u8 *head, size_t head_len,
- u8 *tail, size_t tail_len);
-
- /* Configure internal bridge:
- * 0 = disabled, i.e., client separation is enabled (no bridging of
- * packets between associated STAs
- * 1 = enabled, i.e., bridge packets between associated STAs (default)
- */
- int (*set_internal_bridge)(void *priv, int value);
- int (*set_beacon_int)(void *priv, int value);
- int (*set_dtim_period)(const char *ifname, void *priv, int value);
- /* Configure broadcast SSID mode:
- * 0 = include SSID in Beacon frames and reply to Probe Request frames
- * that use broadcast SSID
- * 1 = hide SSID from Beacon frames and ignore Probe Request frames for
- * broadcast SSID
- */
- int (*set_broadcast_ssid)(void *priv, int value);
- int (*set_cts_protect)(void *priv, int value);
- int (*set_key_tx_rx_threshold)(void *priv, int value);
- int (*set_preamble)(void *priv, int value);
- int (*set_short_slot_time)(void *priv, int value);
- int (*set_tx_queue_params)(void *priv, int queue, int aifs, int cw_min,
- int cw_max, int burst_time);
- int (*bss_add)(void *priv, const char *ifname, const u8 *bssid);
- int (*bss_remove)(void *priv, const char *ifname);
- int (*valid_bss_mask)(void *priv, const u8 *addr, const u8 *mask);
- int (*passive_scan)(void *priv, int now, int our_mode_only,
- int interval, int _listen, int *channel,
- int *last_rx);
- struct hostapd_hw_modes * (*get_hw_feature_data)(void *priv,
- u16 *num_modes,
- u16 *flags);
- int (*if_add)(const char *iface, void *priv,
- enum hostapd_driver_if_type type, char *ifname,
- const u8 *addr);
- int (*if_update)(void *priv, enum hostapd_driver_if_type type,
- char *ifname, const u8 *addr);
- int (*if_remove)(void *priv, enum hostapd_driver_if_type type,
- const char *ifname, const u8 *addr);
- int (*set_sta_vlan)(void *priv, const u8 *addr, const char *ifname,
- int vlan_id);
- /**
- * commit - Optional commit changes handler
- * @priv: driver private data
- * Returns: 0 on success, -1 on failure
- *
- * This optional handler function can be registered if the driver
- * interface implementation needs to commit changes (e.g., by setting
- * network interface up) at the end of initial configuration. If set,
- * this handler will be called after initial setup has been completed.
- */
- int (*commit)(void *priv);
-
- int (*send_ether)(void *priv, const u8 *dst, const u8 *src, u16 proto,
- const u8 *data, size_t data_len);
-
- int (*set_radius_acl_auth)(void *priv, const u8 *mac, int accepted,
- u32 session_timeout);
- int (*set_radius_acl_expire)(void *priv, const u8 *mac);
-
- int (*set_ht_params)(const char *ifname, void *priv,
- const u8 *ht_capab, size_t ht_capab_len,
- const u8 *ht_oper, size_t ht_oper_len);
-
- int (*set_wps_beacon_ie)(const char *ifname, void *priv,
- const u8 *ie, size_t len);
- int (*set_wps_probe_resp_ie)(const char *ifname, void *priv,
- const u8 *ie, size_t len);
-};
-
-static inline void *
-hostapd_driver_init(struct hostapd_data *hapd)
-{
- if (hapd->driver == NULL || hapd->driver->init == NULL)
- return NULL;
- return hapd->driver->init(hapd);
-}
-
-static inline void *
-hostapd_driver_init_bssid(struct hostapd_data *hapd, const u8 *bssid)
-{
- if (hapd->driver == NULL || hapd->driver->init_bssid == NULL)
- return NULL;
- return hapd->driver->init_bssid(hapd, bssid);
-}
-
-static inline void
-hostapd_driver_deinit(struct hostapd_data *hapd)
-{
- if (hapd->driver == NULL || hapd->driver->deinit == NULL)
- return;
- hapd->driver->deinit(hapd->drv_priv);
-}
-
-static inline int
-hostapd_wireless_event_init(struct hostapd_data *hapd)
-{
- if (hapd->driver == NULL ||
- hapd->driver->wireless_event_init == NULL)
- return 0;
- return hapd->driver->wireless_event_init(hapd->drv_priv);
-}
-
-static inline void
-hostapd_wireless_event_deinit(struct hostapd_data *hapd)
-{
- if (hapd->driver == NULL ||
- hapd->driver->wireless_event_deinit == NULL)
- return;
- hapd->driver->wireless_event_deinit(hapd->drv_priv);
-}
-
-static inline int
-hostapd_set_ieee8021x(const char *ifname, struct hostapd_data *hapd,
- int enabled)
-{
- if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
- return 0;
- return hapd->driver->set_ieee8021x(ifname, hapd->drv_priv, enabled);
-}
-
-static inline int
-hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
-{
- if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
- return 0;
- return hapd->driver->set_privacy(hapd->conf->iface, hapd->drv_priv,
- enabled);
-}
-
-static inline int
-hostapd_set_encryption(const char *ifname, struct hostapd_data *hapd,
- const char *alg, const u8 *addr, int idx,
- u8 *key, size_t key_len, int txkey)
-{
- if (hapd->driver == NULL || hapd->driver->set_encryption == NULL)
- return 0;
- return hapd->driver->set_encryption(ifname, hapd->drv_priv, alg, addr,
- idx, key, key_len, txkey);
-}
-
-static inline int
-hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
- const u8 *addr, int idx, u8 *seq)
-{
- if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
- return 0;
- return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx,
- seq);
-}
-
-static inline int
-hostapd_get_seqnum_igtk(const char *ifname, struct hostapd_data *hapd,
- const u8 *addr, int idx, u8 *seq)
-{
- if (hapd->driver == NULL || hapd->driver->get_seqnum_igtk == NULL)
- return -1;
- return hapd->driver->get_seqnum_igtk(ifname, hapd->drv_priv, addr, idx,
- seq);
-}
-
-static inline int
-hostapd_flush(struct hostapd_data *hapd)
-{
- if (hapd->driver == NULL || hapd->driver->flush == NULL)
- return 0;
- return hapd->driver->flush(hapd->drv_priv);
-}
-
-static inline int
-hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
- size_t elem_len)
-{
- if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
- return 0;
- return hapd->driver->set_generic_elem(hapd->conf->iface,
- hapd->drv_priv, elem, elem_len);
-}
-
-static inline int
-hostapd_read_sta_data(struct hostapd_data *hapd,
- struct hostap_sta_driver_data *data, const u8 *addr)
-{
- if (hapd->driver == NULL || hapd->driver->read_sta_data == NULL)
- return -1;
- return hapd->driver->read_sta_data(hapd->drv_priv, data, addr);
-}
-
-static inline int
-hostapd_send_eapol(struct hostapd_data *hapd, const u8 *addr, const u8 *data,
- size_t data_len, int encrypt)
-{
- if (hapd->driver == NULL || hapd->driver->send_eapol == NULL)
- return 0;
- return hapd->driver->send_eapol(hapd->drv_priv, addr, data, data_len,
- encrypt, hapd->own_addr);
-}
-
-static inline int
-hostapd_sta_deauth(struct hostapd_data *hapd, const u8 *addr, int reason)
-{
- if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
- return 0;
- return hapd->driver->sta_deauth(hapd->drv_priv, addr, reason);
-}
-
-static inline int
-hostapd_sta_disassoc(struct hostapd_data *hapd, const u8 *addr, int reason)
-{
- if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
- return 0;
- return hapd->driver->sta_disassoc(hapd->drv_priv, addr, reason);
-}
-
-static inline int
-hostapd_sta_remove(struct hostapd_data *hapd, const u8 *addr)
-{
- if (hapd->driver == NULL || hapd->driver->sta_remove == NULL)
- return 0;
- return hapd->driver->sta_remove(hapd->drv_priv, addr);
-}
-
-static inline int
-hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
-{
- if (hapd->driver == NULL || hapd->driver->get_ssid == NULL)
- return 0;
- return hapd->driver->get_ssid(hapd->conf->iface, hapd->drv_priv, buf,
- len);
-}
-
-static inline int
-hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
-{
- if (hapd->driver == NULL || hapd->driver->set_ssid == NULL)
- return 0;
- return hapd->driver->set_ssid(hapd->conf->iface, hapd->drv_priv, buf,
- len);
-}
-
-static inline int
-hostapd_send_mgmt_frame(struct hostapd_data *hapd, const void *msg, size_t len,
- int flags)
-{
- if (hapd->driver == NULL || hapd->driver->send_mgmt_frame == NULL)
- return 0;
- return hapd->driver->send_mgmt_frame(hapd->drv_priv, msg, len, flags);
-}
-
-static inline int
-hostapd_set_assoc_ap(struct hostapd_data *hapd, const u8 *addr)
-{
- if (hapd->driver == NULL || hapd->driver->set_assoc_ap == NULL)
- return 0;
- return hapd->driver->set_assoc_ap(hapd->drv_priv, addr);
-}
-
-static inline int
-hostapd_set_countermeasures(struct hostapd_data *hapd, int enabled)
-{
- if (hapd->driver == NULL || hapd->driver->set_countermeasures == NULL)
- return 0;
- return hapd->driver->set_countermeasures(hapd->drv_priv, enabled);
-}
-
-static inline int
-hostapd_sta_add(const char *ifname, struct hostapd_data *hapd, const u8 *addr,
- u16 aid, u16 capability, const u8 *supp_rates,
- size_t supp_rates_len, int flags, u16 listen_interval,
- const struct ht_cap_ie *ht_capabilities)
-{
- if (hapd->driver == NULL)
- return 0;
-
- if (hapd->driver->sta_add2) {
- struct hostapd_sta_add_params params;
- os_memset(&params, 0, sizeof(params));
- params.addr = addr;
- params.aid = aid;
- params.capability = capability;
- params.supp_rates = supp_rates;
- params.supp_rates_len = supp_rates_len;
- params.flags = flags;
- params.listen_interval = listen_interval;
- params.ht_capabilities = ht_capabilities;
- return hapd->driver->sta_add2(ifname, hapd->drv_priv, &params);
- }
-
- if (hapd->driver->sta_add == NULL)
- return 0;
- return hapd->driver->sta_add(ifname, hapd->drv_priv, addr, aid,
- capability, (u8 *) supp_rates,
- supp_rates_len,
- flags, listen_interval);
-}
-
-static inline int
-hostapd_get_inact_sec(struct hostapd_data *hapd, const u8 *addr)
-{
- if (hapd->driver == NULL || hapd->driver->get_inact_sec == NULL)
- return 0;
- return hapd->driver->get_inact_sec(hapd->drv_priv, addr);
-}
-
-static inline int
-hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq, int ht_enabled,
- int sec_channel_offset)
-{
- if (hapd->driver == NULL)
- return 0;
- if (hapd->driver->set_freq2) {
- struct hostapd_freq_params data;
- os_memset(&data, 0, sizeof(data));
- data.mode = mode;
- data.freq = freq;
- data.ht_enabled = ht_enabled;
- data.sec_channel_offset = sec_channel_offset;
- return hapd->driver->set_freq2(hapd->drv_priv, &data);
- }
-
- if (hapd->driver->set_freq == NULL)
- return 0;
- return hapd->driver->set_freq(hapd->drv_priv, mode, freq);
-}
-
-static inline int
-hostapd_set_rts(struct hostapd_data *hapd, int rts)
-{
- if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
- return 0;
- return hapd->driver->set_rts(hapd->drv_priv, rts);
-}
-
-static inline int
-hostapd_get_rts(struct hostapd_data *hapd, int *rts)
-{
- if (hapd->driver == NULL || hapd->driver->get_rts == NULL)
- return 0;
- return hapd->driver->get_rts(hapd->drv_priv, rts);
-}
-
-static inline int
-hostapd_set_frag(struct hostapd_data *hapd, int frag)
-{
- if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
- return 0;
- return hapd->driver->set_frag(hapd->drv_priv, frag);
-}
-
-static inline int
-hostapd_get_frag(struct hostapd_data *hapd, int *frag)
-{
- if (hapd->driver == NULL || hapd->driver->get_frag == NULL)
- return 0;
- return hapd->driver->get_frag(hapd->drv_priv, frag);
-}
-
-static inline int
-hostapd_set_retry(struct hostapd_data *hapd, int short_retry, int long_retry)
-{
- if (hapd->driver == NULL || hapd->driver->set_retry == NULL)
- return 0;
- return hapd->driver->set_retry(hapd->drv_priv, short_retry,
- long_retry);
-}
-
-static inline int
-hostapd_get_retry(struct hostapd_data *hapd, int *short_retry, int *long_retry)
-{
- if (hapd->driver == NULL || hapd->driver->get_retry == NULL)
- return 0;
- return hapd->driver->get_retry(hapd->drv_priv, short_retry,
- long_retry);
-}
-
-static inline int
-hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
- int total_flags, int flags_or, int flags_and)
-{
- if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL)
- return 0;
- return hapd->driver->sta_set_flags(hapd->drv_priv, addr, total_flags,
- flags_or, flags_and);
-}
-
-static inline int
-hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates,
- int *basic_rates, int mode)
-{
- if (hapd->driver == NULL || hapd->driver->set_rate_sets == NULL)
- return 0;
- return hapd->driver->set_rate_sets(hapd->drv_priv, supp_rates,
- basic_rates, mode);
-}
-
-static inline int
-hostapd_set_regulatory_domain(struct hostapd_data *hapd, unsigned int rd)
-{
- if (hapd->driver == NULL ||
- hapd->driver->set_regulatory_domain == NULL)
- return 0;
- return hapd->driver->set_regulatory_domain(hapd->drv_priv, rd);
-}
-
-static inline int
-hostapd_set_country(struct hostapd_data *hapd, const char *country)
-{
- if (hapd->driver == NULL ||
- hapd->driver->set_country == NULL)
- return 0;
- return hapd->driver->set_country(hapd->drv_priv, country);
-}
-
-static inline int
-hostapd_set_ieee80211d(struct hostapd_data *hapd, int enabled)
-{
- if (hapd->driver == NULL ||
- hapd->driver->set_ieee80211d == NULL)
- return 0;
- return hapd->driver->set_ieee80211d(hapd->drv_priv, enabled);
-}
-
-static inline int
-hostapd_sta_clear_stats(struct hostapd_data *hapd, const u8 *addr)
-{
- if (hapd->driver == NULL || hapd->driver->sta_clear_stats == NULL)
- return 0;
- return hapd->driver->sta_clear_stats(hapd->drv_priv, addr);
-}
-
-static inline int
-hostapd_set_beacon(const char *ifname, struct hostapd_data *hapd,
- u8 *head, size_t head_len,
- u8 *tail, size_t tail_len)
-{
- if (hapd->driver == NULL || hapd->driver->set_beacon == NULL)
- return 0;
- return hapd->driver->set_beacon(ifname, hapd->drv_priv, head, head_len,
- tail, tail_len);
-}
-
-static inline int
-hostapd_set_internal_bridge(struct hostapd_data *hapd, int value)
-{
- if (hapd->driver == NULL || hapd->driver->set_internal_bridge == NULL)
- return 0;
- return hapd->driver->set_internal_bridge(hapd->drv_priv, value);
-}
-
-static inline int
-hostapd_set_beacon_int(struct hostapd_data *hapd, int value)
-{
- if (hapd->driver == NULL || hapd->driver->set_beacon_int == NULL)
- return 0;
- return hapd->driver->set_beacon_int(hapd->drv_priv, value);
-}
-
-static inline int
-hostapd_set_dtim_period(struct hostapd_data *hapd, int value)
-{
- if (hapd->driver == NULL || hapd->driver->set_dtim_period == NULL)
- return 0;
- return hapd->driver->set_dtim_period(hapd->conf->iface, hapd->drv_priv,
- value);
-}
-
-static inline int
-hostapd_set_broadcast_ssid(struct hostapd_data *hapd, int value)
-{
- if (hapd->driver == NULL || hapd->driver->set_broadcast_ssid == NULL)
- return 0;
- return hapd->driver->set_broadcast_ssid(hapd->drv_priv, value);
-}
-
-static inline int
-hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
-{
- if (hapd->driver == NULL || hapd->driver->set_cts_protect == NULL)
- return 0;
- return hapd->driver->set_cts_protect(hapd->drv_priv, value);
-}
-
-static inline int
-hostapd_set_key_tx_rx_threshold(struct hostapd_data *hapd, int value)
-{
- if (hapd->driver == NULL ||
- hapd->driver->set_key_tx_rx_threshold == NULL)
- return 0;
- return hapd->driver->set_key_tx_rx_threshold(hapd->drv_priv, value);
-}
-
-static inline int
-hostapd_set_preamble(struct hostapd_data *hapd, int value)
-{
- if (hapd->driver == NULL || hapd->driver->set_preamble == NULL)
- return 0;
- return hapd->driver->set_preamble(hapd->drv_priv, value);
-}
-
-static inline int
-hostapd_set_short_slot_time(struct hostapd_data *hapd, int value)
-{
- if (hapd->driver == NULL || hapd->driver->set_short_slot_time == NULL)
- return 0;
- return hapd->driver->set_short_slot_time(hapd->drv_priv, value);
-}
-
-static inline int
-hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
- int cw_min, int cw_max, int burst_time)
-{
- if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL)
- return 0;
- return hapd->driver->set_tx_queue_params(hapd->drv_priv, queue, aifs,
- cw_min, cw_max, burst_time);
-}
-
-static inline int
-hostapd_bss_add(struct hostapd_data *hapd, const char *ifname, const u8 *bssid)
-{
- if (hapd->driver == NULL || hapd->driver->bss_add == NULL)
- return 0;
- return hapd->driver->bss_add(hapd->drv_priv, ifname, bssid);
-}
-
-static inline int
-hostapd_bss_remove(struct hostapd_data *hapd, const char *ifname)
-{
- if (hapd->driver == NULL || hapd->driver->bss_remove == NULL)
- return 0;
- return hapd->driver->bss_remove(hapd->drv_priv, ifname);
-}
-
-static inline int
-hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr,
- const u8 *mask)
-{
- if (hapd->driver == NULL || hapd->driver->valid_bss_mask == NULL)
- return 1;
- return hapd->driver->valid_bss_mask(hapd->drv_priv, addr, mask);
-}
-
-static inline int
-hostapd_if_add(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
- char *ifname, const u8 *addr)
-{
- if (hapd->driver == NULL || hapd->driver->if_add == NULL)
- return -1;
- return hapd->driver->if_add(hapd->conf->iface, hapd->drv_priv, type,
- ifname, addr);
-}
-
-static inline int
-hostapd_if_update(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
- char *ifname, const u8 *addr)
-{
- if (hapd->driver == NULL || hapd->driver->if_update == NULL)
- return -1;
- return hapd->driver->if_update(hapd->drv_priv, type, ifname, addr);
-}
-
-static inline int
-hostapd_if_remove(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
- char *ifname, const u8 *addr)
-{
- if (hapd->driver == NULL || hapd->driver->if_remove == NULL)
- return -1;
- return hapd->driver->if_remove(hapd->drv_priv, type, ifname, addr);
-}
-
-static inline int
-hostapd_passive_scan(struct hostapd_data *hapd, int now, int our_mode_only,
- int interval, int _listen, int *channel,
- int *last_rx)
-{
- if (hapd->driver == NULL || hapd->driver->passive_scan == NULL)
- return -1;
- return hapd->driver->passive_scan(hapd->drv_priv, now, our_mode_only,
- interval, _listen, channel, last_rx);
-}
-
-static inline struct hostapd_hw_modes *
-hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
- u16 *flags)
-{
- if (hapd->driver == NULL || hapd->driver->get_hw_feature_data == NULL)
- return NULL;
- return hapd->driver->get_hw_feature_data(hapd->drv_priv, num_modes,
- flags);
-}
-
-static inline int
-hostapd_set_sta_vlan(const char *ifname, struct hostapd_data *hapd,
- const u8 *addr, int vlan_id)
-{
- if (hapd->driver == NULL || hapd->driver->set_sta_vlan == NULL)
- return 0;
- return hapd->driver->set_sta_vlan(hapd->drv_priv, addr, ifname, vlan_id);
-}
-
-static inline int
-hostapd_driver_commit(struct hostapd_data *hapd)
-{
- if (hapd->driver == NULL || hapd->driver->commit == NULL)
- return 0;
- return hapd->driver->commit(hapd->drv_priv);
-}
-
-static inline int
-hostapd_set_radius_acl_auth(struct hostapd_data *hapd, const u8 *mac,
- int accepted, u32 session_timeout)
-{
- if (hapd->driver == NULL || hapd->driver->set_radius_acl_auth == NULL)
- return 0;
- return hapd->driver->set_radius_acl_auth(hapd->drv_priv, mac, accepted,
- session_timeout);
-}
-
-static inline int
-hostapd_set_radius_acl_expire(struct hostapd_data *hapd, const u8 *mac)
-{
- if (hapd->driver == NULL ||
- hapd->driver->set_radius_acl_expire == NULL)
- return 0;
- return hapd->driver->set_radius_acl_expire(hapd->drv_priv, mac);
-}
-
-#ifdef CONFIG_IEEE80211N
-static inline int
-hostapd_set_ht_params(const char *ifname, struct hostapd_data *hapd,
- const u8 *ht_capab, size_t ht_capab_len,
- const u8 *ht_oper, size_t ht_oper_len)
-{
- if (hapd->driver == NULL || hapd->driver->set_ht_params == NULL ||
- ht_capab == NULL || ht_oper == NULL)
- return 0;
- return hapd->driver->set_ht_params(
- ifname, hapd->drv_priv, ht_capab, ht_capab_len,
- ht_oper, ht_oper_len);
-}
-#endif /* CONFIG_IEEE80211N */
-
-static inline int
-hostapd_drv_none(struct hostapd_data *hapd)
-{
- return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0;
-}
-
-static inline int
-hostapd_set_wps_beacon_ie(struct hostapd_data *hapd, const u8 *ie, size_t len)
-{
- if (hapd->driver == NULL || hapd->driver->set_wps_beacon_ie == NULL)
- return 0;
- return hapd->driver->set_wps_beacon_ie(hapd->conf->iface,
- hapd->drv_priv, ie, len);
-}
-
-static inline int
-hostapd_set_wps_probe_resp_ie(struct hostapd_data *hapd, const u8 *ie,
- size_t len)
-{
- if (hapd->driver == NULL ||
- hapd->driver->set_wps_probe_resp_ie == NULL)
- return 0;
- return hapd->driver->set_wps_probe_resp_ie(hapd->conf->iface,
- hapd->drv_priv, ie, len);
-}
-
-#endif /* DRIVER_H */
diff --git a/hostapd/driver_bsd.c b/hostapd/driver_bsd.c
deleted file mode 100644
index 43d57d9091d3..000000000000
--- a/hostapd/driver_bsd.c
+++ /dev/null
@@ -1,839 +0,0 @@
-/*
- * hostapd / Driver interaction with BSD net80211 layer
- * Copyright (c) 2004, Sam Leffler <sam@errno.com>
- * Copyright (c) 2004, 2Wire, Inc
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Alternatively, this software may be distributed under the terms of BSD
- * license.
- *
- * See README and COPYING for more details.
- */
-
-#include "includes.h"
-#include <sys/ioctl.h>
-
-#include <net/if.h>
-
-#include <net80211/ieee80211.h>
-#include <net80211/ieee80211_crypto.h>
-#include <net80211/ieee80211_ioctl.h>
-
-/*
- * Avoid conflicts with hostapd definitions by undefining couple of defines
- * from net80211 header files.
- */
-#undef RSN_VERSION
-#undef WPA_VERSION
-#undef WPA_OUI_TYPE
-#undef WME_OUI_TYPE
-
-#include "hostapd.h"
-#include "driver.h"
-#include "ieee802_1x.h"
-#include "eloop.h"
-#include "sta_info.h"
-#include "l2_packet/l2_packet.h"
-
-#include "eapol_sm.h"
-#include "wpa.h"
-#include "radius/radius.h"
-#include "ieee802_11.h"
-#include "common.h"
-
-struct bsd_driver_data {
- struct hostapd_data *hapd; /* back pointer */
-
- char iface[IFNAMSIZ + 1];
- struct l2_packet_data *sock_xmit; /* raw packet xmit socket */
- int ioctl_sock; /* socket for ioctl() use */
- int wext_sock; /* socket for wireless events */
-};
-
-static int bsd_sta_deauth(void *priv, const u8 *addr, int reason_code);
-
-static int
-set80211var(struct bsd_driver_data *drv, int op, const void *arg, int arg_len)
-{
- struct ieee80211req ireq;
-
- memset(&ireq, 0, sizeof(ireq));
- os_strlcpy(ireq.i_name, drv->iface, IFNAMSIZ);
- ireq.i_type = op;
- ireq.i_len = arg_len;
- ireq.i_data = (void *) arg;
-
- if (ioctl(drv->ioctl_sock, SIOCS80211, &ireq) < 0) {
- perror("ioctl[SIOCS80211]");
- return -1;
- }
- return 0;
-}
-
-static int
-get80211var(struct bsd_driver_data *drv, int op, void *arg, int arg_len)
-{
- struct ieee80211req ireq;
-
- memset(&ireq, 0, sizeof(ireq));
- os_strlcpy(ireq.i_name, drv->iface, IFNAMSIZ);
- ireq.i_type = op;
- ireq.i_len = arg_len;
- ireq.i_data = arg;
-
- if (ioctl(drv->ioctl_sock, SIOCG80211, &ireq) < 0) {
- perror("ioctl[SIOCG80211]");
- return -1;
- }
- return ireq.i_len;
-}
-
-static int
-set80211param(struct bsd_driver_data *drv, int op, int arg)
-{
- struct ieee80211req ireq;
-
- memset(&ireq, 0, sizeof(ireq));
- os_strlcpy(ireq.i_name, drv->iface, IFNAMSIZ);
- ireq.i_type = op;
- ireq.i_val = arg;
-
- if (ioctl(drv->ioctl_sock, SIOCS80211, &ireq) < 0) {
- perror("ioctl[SIOCS80211]");
- return -1;
- }
- return 0;
-}
-
-static const char *
-ether_sprintf(const u8 *addr)
-{
- static char buf[sizeof(MACSTR)];
-
- if (addr != NULL)
- snprintf(buf, sizeof(buf), MACSTR, MAC2STR(addr));
- else
- snprintf(buf, sizeof(buf), MACSTR, 0,0,0,0,0,0);
- return buf;
-}
-
-/*
- * Configure WPA parameters.
- */
-static int
-bsd_configure_wpa(struct bsd_driver_data *drv)
-{
- static const char *ciphernames[] =
- { "WEP", "TKIP", "AES-OCB", "AES-CCM", "CKIP", "NONE" };
- struct hostapd_data *hapd = drv->hapd;
- struct hostapd_bss_config *conf = hapd->conf;
- int v;
-
- switch (conf->wpa_group) {
- case WPA_CIPHER_CCMP:
- v = IEEE80211_CIPHER_AES_CCM;
- break;
- case WPA_CIPHER_TKIP:
- v = IEEE80211_CIPHER_TKIP;
- break;
- case WPA_CIPHER_WEP104:
- v = IEEE80211_CIPHER_WEP;
- break;
- case WPA_CIPHER_WEP40:
- v = IEEE80211_CIPHER_WEP;
- break;
- case WPA_CIPHER_NONE:
- v = IEEE80211_CIPHER_NONE;
- break;
- default:
- printf("Unknown group key cipher %u\n",
- conf->wpa_group);
- return -1;
- }
- wpa_printf(MSG_DEBUG, "%s: group key cipher=%s (%u)",
- __func__, ciphernames[v], v);
- if (set80211param(drv, IEEE80211_IOC_MCASTCIPHER, v)) {
- printf("Unable to set group key cipher to %u (%s)\n",
- v, ciphernames[v]);
- return -1;
- }
- if (v == IEEE80211_CIPHER_WEP) {
- /* key length is done only for specific ciphers */
- v = (conf->wpa_group == WPA_CIPHER_WEP104 ? 13 : 5);
- if (set80211param(drv, IEEE80211_IOC_MCASTKEYLEN, v)) {
- printf("Unable to set group key length to %u\n", v);
- return -1;
- }
- }
-
- v = 0;
- if (conf->wpa_pairwise & WPA_CIPHER_CCMP)
- v |= 1<<IEEE80211_CIPHER_AES_CCM;
- if (conf->wpa_pairwise & WPA_CIPHER_TKIP)
- v |= 1<<IEEE80211_CIPHER_TKIP;
- if (conf->wpa_pairwise & WPA_CIPHER_NONE)
- v |= 1<<IEEE80211_CIPHER_NONE;
- wpa_printf(MSG_DEBUG, "%s: pairwise key ciphers=0x%x", __func__, v);
- if (set80211param(drv, IEEE80211_IOC_UCASTCIPHERS, v)) {
- printf("Unable to set pairwise key ciphers to 0x%x\n", v);
- return -1;
- }
-
- wpa_printf(MSG_DEBUG, "%s: key management algorithms=0x%x",
- __func__, conf->wpa_key_mgmt);
- if (set80211param(drv, IEEE80211_IOC_KEYMGTALGS, conf->wpa_key_mgmt)) {
- printf("Unable to set key management algorithms to 0x%x\n",
- conf->wpa_key_mgmt);
- return -1;
- }
-
- v = 0;
- if (conf->rsn_preauth)
- v |= BIT(0);
- wpa_printf(MSG_DEBUG, "%s: rsn capabilities=0x%x",
- __func__, conf->rsn_preauth);
- if (set80211param(drv, IEEE80211_IOC_RSNCAPS, v)) {
- printf("Unable to set RSN capabilities to 0x%x\n", v);
- return -1;
- }
-
- wpa_printf(MSG_DEBUG, "%s: enable WPA= 0x%x", __func__, conf->wpa);
- if (set80211param(drv, IEEE80211_IOC_WPA, conf->wpa)) {
- printf("Unable to set WPA to %u\n", conf->wpa);
- return -1;
- }
- return 0;
-}
-
-
-static int
-bsd_set_iface_flags(void *priv, int dev_up)
-{
- struct bsd_driver_data *drv = priv;
- struct ifreq ifr;
-
- wpa_printf(MSG_DEBUG, "%s: dev_up=%d", __func__, dev_up);
-
- if (drv->ioctl_sock < 0)
- return -1;
-
- memset(&ifr, 0, sizeof(ifr));
- os_strlcpy(ifr.ifr_name, drv->iface, IFNAMSIZ);
-
- if (ioctl(drv->ioctl_sock, SIOCGIFFLAGS, &ifr) != 0) {
- perror("ioctl[SIOCGIFFLAGS]");
- return -1;
- }
-
- if (dev_up)
- ifr.ifr_flags |= IFF_UP;
- else
- ifr.ifr_flags &= ~IFF_UP;
-
- if (ioctl(drv->ioctl_sock, SIOCSIFFLAGS, &ifr) != 0) {
- perror("ioctl[SIOCSIFFLAGS]");
- return -1;
- }
-
- if (dev_up) {
- memset(&ifr, 0, sizeof(ifr));
- os_strlcpy(ifr.ifr_name, drv->iface, IFNAMSIZ);
- ifr.ifr_mtu = HOSTAPD_MTU;
- if (ioctl(drv->ioctl_sock, SIOCSIFMTU, &ifr) != 0) {
- perror("ioctl[SIOCSIFMTU]");
- printf("Setting MTU failed - trying to survive with "
- "current value\n");
- }
- }
-
- return 0;
-}
-
-static int
-bsd_set_ieee8021x(const char *ifname, void *priv, int enabled)
-{
- struct bsd_driver_data *drv = priv;
- struct hostapd_data *hapd = drv->hapd;
- struct hostapd_bss_config *conf = hapd->conf;
-
- wpa_printf(MSG_DEBUG, "%s: enabled=%d", __func__, enabled);
-
- if (!enabled) {
- /* XXX restore state */
- return set80211param(priv, IEEE80211_IOC_AUTHMODE,
- IEEE80211_AUTH_AUTO);
- }
- if (!conf->wpa && !conf->ieee802_1x) {
- hostapd_logger(hapd, NULL, HOSTAPD_MODULE_DRIVER,
- HOSTAPD_LEVEL_WARNING, "No 802.1X or WPA enabled!");
- return -1;
- }
- if (conf->wpa && bsd_configure_wpa(drv) != 0) {
- hostapd_logger(hapd, NULL, HOSTAPD_MODULE_DRIVER,
- HOSTAPD_LEVEL_WARNING, "Error configuring WPA state!");
- return -1;
- }
- if (set80211param(priv, IEEE80211_IOC_AUTHMODE,
- (conf->wpa ? IEEE80211_AUTH_WPA : IEEE80211_AUTH_8021X))) {
- hostapd_logger(hapd, NULL, HOSTAPD_MODULE_DRIVER,
- HOSTAPD_LEVEL_WARNING, "Error enabling WPA/802.1X!");
- return -1;
- }
- return bsd_set_iface_flags(priv, 1);
-}
-
-static int
-bsd_set_privacy(const char *ifname, void *priv, int enabled)
-{
- struct bsd_driver_data *drv = priv;
-
- wpa_printf(MSG_DEBUG, "%s: enabled=%d", __func__, enabled);
-
- return set80211param(drv, IEEE80211_IOC_PRIVACY, enabled);
-}
-
-static int
-bsd_set_sta_authorized(void *priv, const u8 *addr, int authorized)
-{
- struct bsd_driver_data *drv = priv;
- struct ieee80211req_mlme mlme;
-
- wpa_printf(MSG_DEBUG, "%s: addr=%s authorized=%d",
- __func__, ether_sprintf(addr), authorized);
-
- if (authorized)
- mlme.im_op = IEEE80211_MLME_AUTHORIZE;
- else
- mlme.im_op = IEEE80211_MLME_UNAUTHORIZE;
- mlme.im_reason = 0;
- memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
- return set80211var(drv, IEEE80211_IOC_MLME, &mlme, sizeof(mlme));
-}
-
-static int
-bsd_sta_set_flags(void *priv, const u8 *addr, int total_flags, int flags_or,
- int flags_and)
-{
- /* For now, only support setting Authorized flag */
- if (flags_or & WLAN_STA_AUTHORIZED)
- return bsd_set_sta_authorized(priv, addr, 1);
- if (!(flags_and & WLAN_STA_AUTHORIZED))
- return bsd_set_sta_authorized(priv, addr, 0);
- return 0;
-}
-
-static int
-bsd_del_key(void *priv, const u8 *addr, int key_idx)
-{
- struct bsd_driver_data *drv = priv;
- struct ieee80211req_del_key wk;
-
- wpa_printf(MSG_DEBUG, "%s: addr=%s key_idx=%d",
- __func__, ether_sprintf(addr), key_idx);
-
- memset(&wk, 0, sizeof(wk));
- if (addr != NULL) {
- memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
- wk.idk_keyix = (u_int8_t) IEEE80211_KEYIX_NONE; /* XXX */
- } else {
- wk.idk_keyix = key_idx;
- }
-
- return set80211var(drv, IEEE80211_IOC_DELKEY, &wk, sizeof(wk));
-}
-
-static int
-bsd_set_key(const char *ifname, void *priv, const char *alg,
- const u8 *addr, int key_idx,
- const u8 *key, size_t key_len, int txkey)
-{
- struct bsd_driver_data *drv = priv;
- struct ieee80211req_key wk;
- u_int8_t cipher;
-
- if (strcmp(alg, "none") == 0)
- return bsd_del_key(drv, addr, key_idx);
-
- wpa_printf(MSG_DEBUG, "%s: alg=%s addr=%s key_idx=%d",
- __func__, alg, ether_sprintf(addr), key_idx);
-
- if (strcmp(alg, "WEP") == 0)
- cipher = IEEE80211_CIPHER_WEP;
- else if (strcmp(alg, "TKIP") == 0)
- cipher = IEEE80211_CIPHER_TKIP;
- else if (strcmp(alg, "CCMP") == 0)
- cipher = IEEE80211_CIPHER_AES_CCM;
- else {
- printf("%s: unknown/unsupported algorithm %s\n",
- __func__, alg);
- return -1;
- }
-
- if (key_len > sizeof(wk.ik_keydata)) {
- printf("%s: key length %d too big\n", __func__, key_len);
- return -3;
- }
-
- memset(&wk, 0, sizeof(wk));
- wk.ik_type = cipher;
- wk.ik_flags = IEEE80211_KEY_RECV | IEEE80211_KEY_XMIT;
- if (addr == NULL) {
- memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
- wk.ik_keyix = key_idx;
- wk.ik_flags |= IEEE80211_KEY_DEFAULT;
- } else {
- memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
- wk.ik_keyix = IEEE80211_KEYIX_NONE;
- }
- wk.ik_keylen = key_len;
- memcpy(wk.ik_keydata, key, key_len);
-
- return set80211var(drv, IEEE80211_IOC_WPAKEY, &wk, sizeof(wk));
-}
-
-
-static int
-bsd_get_seqnum(const char *ifname, void *priv, const u8 *addr, int idx,
- u8 *seq)
-{
- struct bsd_driver_data *drv = priv;
- struct ieee80211req_key wk;
-
- wpa_printf(MSG_DEBUG, "%s: addr=%s idx=%d",
- __func__, ether_sprintf(addr), idx);
-
- memset(&wk, 0, sizeof(wk));
- if (addr == NULL)
- memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
- else
- memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
- wk.ik_keyix = idx;
-
- if (get80211var(drv, IEEE80211_IOC_WPAKEY, &wk, sizeof(wk)) < 0) {
- printf("Failed to get encryption.\n");
- return -1;
- }
-
-#ifdef WORDS_BIGENDIAN
- {
- /*
- * wk.ik_keytsc is in host byte order (big endian), need to
- * swap it to match with the byte order used in WPA.
- */
- int i;
- u8 tmp[WPA_KEY_RSC_LEN];
- memcpy(tmp, &wk.ik_keytsc, sizeof(wk.ik_keytsc));
- for (i = 0; i < WPA_KEY_RSC_LEN; i++) {
- seq[i] = tmp[WPA_KEY_RSC_LEN - i - 1];
- }
- }
-#else /* WORDS_BIGENDIAN */
- memcpy(seq, &wk.ik_keytsc, sizeof(wk.ik_keytsc));
-#endif /* WORDS_BIGENDIAN */
- return 0;
-}
-
-
-static int
-bsd_flush(void *priv)
-{
- u8 allsta[IEEE80211_ADDR_LEN];
-
- memset(allsta, 0xff, IEEE80211_ADDR_LEN);
- return bsd_sta_deauth(priv, allsta, IEEE80211_REASON_AUTH_LEAVE);
-}
-
-
-static int
-bsd_read_sta_driver_data(void *priv, struct hostap_sta_driver_data *data,
- const u8 *addr)
-{
- struct bsd_driver_data *drv = priv;
- struct ieee80211req_sta_stats stats;
-
- memcpy(stats.is_u.macaddr, addr, IEEE80211_ADDR_LEN);
- if (get80211var(drv, IEEE80211_IOC_STA_STATS, &stats, sizeof(stats)) > 0) {
- /* XXX? do packets counts include non-data frames? */
- data->rx_packets = stats.is_stats.ns_rx_data;
- data->rx_bytes = stats.is_stats.ns_rx_bytes;
- data->tx_packets = stats.is_stats.ns_tx_data;
- data->tx_bytes = stats.is_stats.ns_tx_bytes;
- }
- return 0;
-}
-
-static int
-bsd_set_opt_ie(const char *ifname, void *priv, const u8 *ie, size_t ie_len)
-{
- /*
- * Do nothing; we setup parameters at startup that define the
- * contents of the beacon information element.
- */
- return 0;
-}
-
-static int
-bsd_sta_deauth(void *priv, const u8 *addr, int reason_code)
-{
- struct bsd_driver_data *drv = priv;
- struct ieee80211req_mlme mlme;
-
- wpa_printf(MSG_DEBUG, "%s: addr=%s reason_code=%d",
- __func__, ether_sprintf(addr), reason_code);
-
- mlme.im_op = IEEE80211_MLME_DEAUTH;
- mlme.im_reason = reason_code;
- memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
- return set80211var(drv, IEEE80211_IOC_MLME, &mlme, sizeof(mlme));
-}
-
-static int
-bsd_sta_disassoc(void *priv, const u8 *addr, int reason_code)
-{
- struct bsd_driver_data *drv = priv;
- struct ieee80211req_mlme mlme;
-
- wpa_printf(MSG_DEBUG, "%s: addr=%s reason_code=%d",
- __func__, ether_sprintf(addr), reason_code);
-
- mlme.im_op = IEEE80211_MLME_DISASSOC;
- mlme.im_reason = reason_code;
- memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
- return set80211var(drv, IEEE80211_IOC_MLME, &mlme, sizeof(mlme));
-}
-
-static int
-bsd_del_sta(struct bsd_driver_data *drv, u8 addr[IEEE80211_ADDR_LEN])
-{
- struct hostapd_data *hapd = drv->hapd;
- struct hostapd_bss_config *conf = hapd->conf;
- struct sta_info *sta;
-
- hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
- HOSTAPD_LEVEL_INFO, "deassociated");
-
- sta = ap_get_sta(hapd, addr);
- if (sta != NULL) {
- sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
- if (conf->wpa)
- wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC);
- sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
- ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
- ap_free_sta(hapd, sta);
- }
- return 0;
-}
-
-static int
-bsd_new_sta(struct bsd_driver_data *drv, u8 addr[IEEE80211_ADDR_LEN])
-{
- struct hostapd_data *hapd = drv->hapd;
- struct hostapd_bss_config *conf = hapd->conf;
- struct sta_info *sta;
- struct ieee80211req_wpaie ie;
- int new_assoc, ielen, res;
-
- hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
- HOSTAPD_LEVEL_INFO, "associated");
-
- sta = ap_sta_add(hapd, addr);
- if (sta == NULL)
- return -1;
- /*
- * Fetch and validate any negotiated WPA/RSN parameters.
- */
- if (conf->wpa) {
- memset(&ie, 0, sizeof(ie));
- memcpy(ie.wpa_macaddr, addr, IEEE80211_ADDR_LEN);
- if (get80211var(drv, IEEE80211_IOC_WPAIE, &ie, sizeof(ie)) < 0) {
- printf("Failed to get WPA/RSN information element.\n");
- return -1; /* XXX not right */
- }
- ielen = ie.wpa_ie[1];
- if (ielen == 0) {
- printf("No WPA/RSN information element for station!\n");
- return -1; /* XXX not right */
- }
- ielen += 2;
- if (sta->wpa_sm == NULL)
- sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth,
- sta->addr);
- if (sta->wpa_sm == NULL) {
- printf("Failed to initialize WPA state machine\n");
- return -1;
- }
- res = wpa_validate_wpa_ie(hapd->wpa_auth, sta->wpa_sm,
- ie.wpa_ie, ielen, NULL, 0);
- if (res != WPA_IE_OK) {
- printf("WPA/RSN information element rejected? "
- "(res %u)\n", res);
- return -1;
- }
- }
-
- /*
- * Now that the internal station state is setup
- * kick the authenticator into action.
- */
- new_assoc = (sta->flags & WLAN_STA_ASSOC) == 0;
- sta->flags |= WLAN_STA_AUTH | WLAN_STA_ASSOC;
- wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC);
- hostapd_new_assoc_sta(hapd, sta, !new_assoc);
- ieee802_1x_notify_port_enabled(sta->eapol_sm, 1);
- return 0;
-}
-
-#include <net/route.h>
-#include <net80211/ieee80211_freebsd.h>
-
-static void
-bsd_wireless_event_receive(int sock, void *ctx, void *sock_ctx)
-{
- struct bsd_driver_data *drv = ctx;
- struct hostapd_data *hapd = drv->hapd;
- char buf[2048];
- struct if_announcemsghdr *ifan;
- struct rt_msghdr *rtm;
- struct ieee80211_michael_event *mic;
- struct ieee80211_join_event *join;
- struct ieee80211_leave_event *leave;
- int n;
-
- n = read(sock, buf, sizeof(buf));
- if (n < 0) {
- if (errno != EINTR && errno != EAGAIN)
- perror("read(PF_ROUTE)");
- return;
- }
-
- rtm = (struct rt_msghdr *) buf;
- if (rtm->rtm_version != RTM_VERSION) {
- wpa_printf(MSG_DEBUG, "Routing message version %d not "
- "understood\n", rtm->rtm_version);
- return;
- }
- ifan = (struct if_announcemsghdr *) rtm;
- switch (rtm->rtm_type) {
- case RTM_IEEE80211:
- switch (ifan->ifan_what) {
- case RTM_IEEE80211_ASSOC:
- case RTM_IEEE80211_REASSOC:
- case RTM_IEEE80211_DISASSOC:
- case RTM_IEEE80211_SCAN:
- break;
- case RTM_IEEE80211_LEAVE:
- leave = (struct ieee80211_leave_event *) &ifan[1];
- bsd_del_sta(drv, leave->iev_addr);
- break;
- case RTM_IEEE80211_JOIN:
-#ifdef RTM_IEEE80211_REJOIN
- case RTM_IEEE80211_REJOIN:
-#endif
- join = (struct ieee80211_join_event *) &ifan[1];
- bsd_new_sta(drv, join->iev_addr);
- break;
- case RTM_IEEE80211_REPLAY:
- /* ignore */
- break;
- case RTM_IEEE80211_MICHAEL:
- mic = (struct ieee80211_michael_event *) &ifan[1];
- wpa_printf(MSG_DEBUG,
- "Michael MIC failure wireless event: "
- "keyix=%u src_addr=" MACSTR, mic->iev_keyix,
- MAC2STR(mic->iev_src));
- ieee80211_michael_mic_failure(hapd, mic->iev_src, 1);
- break;
- }
- break;
- }
-}
-
-static int
-bsd_wireless_event_init(void *priv)
-{
- struct bsd_driver_data *drv = priv;
- int s;
-
- drv->wext_sock = -1;
-
- s = socket(PF_ROUTE, SOCK_RAW, 0);
- if (s < 0) {
- perror("socket(PF_ROUTE,SOCK_RAW)");
- return -1;
- }
- eloop_register_read_sock(s, bsd_wireless_event_receive, drv, NULL);
- drv->wext_sock = s;
-
- return 0;
-}
-
-static void
-bsd_wireless_event_deinit(void *priv)
-{
- struct bsd_driver_data *drv = priv;
-
- if (drv != NULL) {
- if (drv->wext_sock < 0)
- return;
- eloop_unregister_read_sock(drv->wext_sock);
- close(drv->wext_sock);
- }
-}
-
-
-static int
-bsd_send_eapol(void *priv, const u8 *addr, const u8 *data, size_t data_len,
- int encrypt, const u8 *own_addr)
-{
- struct bsd_driver_data *drv = priv;
- unsigned char buf[3000];
- unsigned char *bp = buf;
- struct l2_ethhdr *eth;
- size_t len;
- int status;
-
- /*
- * Prepend the Etherent header. If the caller left us
- * space at the front we could just insert it but since
- * we don't know we copy to a local buffer. Given the frequency
- * and size of frames this probably doesn't matter.
- */
- len = data_len + sizeof(struct l2_ethhdr);
- if (len > sizeof(buf)) {
- bp = malloc(len);
- if (bp == NULL) {
- printf("EAPOL frame discarded, cannot malloc temp "
- "buffer of size %u!\n", len);
- return -1;
- }
- }
- eth = (struct l2_ethhdr *) bp;
- memcpy(eth->h_dest, addr, ETH_ALEN);
- memcpy(eth->h_source, own_addr, ETH_ALEN);
- eth->h_proto = htons(ETH_P_EAPOL);
- memcpy(eth+1, data, data_len);
-
- wpa_hexdump(MSG_MSGDUMP, "TX EAPOL", bp, len);
-
- status = l2_packet_send(drv->sock_xmit, addr, ETH_P_EAPOL, bp, len);
-
- if (bp != buf)
- free(bp);
- return status;
-}
-
-static void
-handle_read(void *ctx, const u8 *src_addr, const u8 *buf, size_t len)
-{
- struct bsd_driver_data *drv = ctx;
- struct hostapd_data *hapd = drv->hapd;
- struct sta_info *sta;
-
- sta = ap_get_sta(hapd, src_addr);
- if (!sta || !(sta->flags & WLAN_STA_ASSOC)) {
- printf("Data frame from not associated STA %s\n",
- ether_sprintf(src_addr));
- /* XXX cannot happen */
- return;
- }
- ieee802_1x_receive(hapd, src_addr, buf + sizeof(struct l2_ethhdr),
- len - sizeof(struct l2_ethhdr));
-}
-
-static int
-bsd_get_ssid(const char *ifname, void *priv, u8 *buf, int len)
-{
- struct bsd_driver_data *drv = priv;
- int ssid_len = get80211var(drv, IEEE80211_IOC_SSID, buf, len);
-
- wpa_printf(MSG_DEBUG, "%s: ssid=\"%.*s\"", __func__, ssid_len, buf);
-
- return ssid_len;
-}
-
-static int
-bsd_set_ssid(const char *ifname, void *priv, const u8 *buf, int len)
-{
- struct bsd_driver_data *drv = priv;
-
- wpa_printf(MSG_DEBUG, "%s: ssid=\"%.*s\"", __func__, len, buf);
-
- return set80211var(drv, IEEE80211_IOC_SSID, buf, len);
-}
-
-static void *
-bsd_init(struct hostapd_data *hapd)
-{
- struct bsd_driver_data *drv;
-
- drv = os_zalloc(sizeof(struct bsd_driver_data));
- if (drv == NULL) {
- printf("Could not allocate memory for bsd driver data\n");
- goto bad;
- }
-
- drv->hapd = hapd;
- drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
- if (drv->ioctl_sock < 0) {
- perror("socket[PF_INET,SOCK_DGRAM]");
- goto bad;
- }
- memcpy(drv->iface, hapd->conf->iface, sizeof(drv->iface));
-
- drv->sock_xmit = l2_packet_init(drv->iface, NULL, ETH_P_EAPOL,
- handle_read, drv, 1);
- if (drv->sock_xmit == NULL)
- goto bad;
- if (l2_packet_get_own_addr(drv->sock_xmit, hapd->own_addr))
- goto bad;
-
- bsd_set_iface_flags(drv, 0); /* mark down during setup */
-
- return drv;
-bad:
- if (drv->sock_xmit != NULL)
- l2_packet_deinit(drv->sock_xmit);
- if (drv->ioctl_sock >= 0)
- close(drv->ioctl_sock);
- if (drv != NULL)
- free(drv);
- return NULL;
-}
-
-
-static void
-bsd_deinit(void *priv)
-{
- struct bsd_driver_data *drv = priv;
-
- (void) bsd_set_iface_flags(drv, 0);
- if (drv->ioctl_sock >= 0)
- close(drv->ioctl_sock);
- if (drv->sock_xmit != NULL)
- l2_packet_deinit(drv->sock_xmit);
- free(drv);
-}
-
-const struct wpa_driver_ops wpa_driver_bsd_ops = {
- .name = "bsd",
- .init = bsd_init,
- .deinit = bsd_deinit,
- .set_ieee8021x = bsd_set_ieee8021x,
- .set_privacy = bsd_set_privacy,
- .set_encryption = bsd_set_key,
- .get_seqnum = bsd_get_seqnum,
- .flush = bsd_flush,
- .set_generic_elem = bsd_set_opt_ie,
- .wireless_event_init = bsd_wireless_event_init,
- .wireless_event_deinit = bsd_wireless_event_deinit,
- .sta_set_flags = bsd_sta_set_flags,
- .read_sta_data = bsd_read_sta_driver_data,
- .send_eapol = bsd_send_eapol,
- .sta_disassoc = bsd_sta_disassoc,
- .sta_deauth = bsd_sta_deauth,
- .set_ssid = bsd_set_ssid,
- .get_ssid = bsd_get_ssid,
-};
diff --git a/hostapd/driver_hostap.c b/hostapd/driver_hostap.c
deleted file mode 100644
index ceff0998919c..000000000000
--- a/hostapd/driver_hostap.c
+++ /dev/null
@@ -1,1279 +0,0 @@
-/*
- * hostapd / Kernel driver communication with Linux Host AP driver
- * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Alternatively, this software may be distributed under the terms of BSD
- * license.
- *
- * See README and COPYING for more details.
- */
-
-#include "includes.h"
-#include <sys/ioctl.h>
-
-#ifdef USE_KERNEL_HEADERS
-/* compat-wireless does not include linux/compiler.h to define __user, so
- * define it here */
-#ifndef __user
-#define __user
-#endif /* __user */
-#include <asm/types.h>
-#include <linux/if_packet.h>
-#include <linux/if_ether.h> /* The L2 protocols */
-#include <linux/if_arp.h>
-#include <linux/wireless.h>
-#else /* USE_KERNEL_HEADERS */
-#include <net/if_arp.h>
-#include <netpacket/packet.h>
-#include "wireless_copy.h"
-#endif /* USE_KERNEL_HEADERS */
-
-#include "hostapd.h"
-#include "driver.h"
-#include "ieee802_1x.h"
-#include "eloop.h"
-#include "priv_netlink.h"
-#include "ieee802_11.h"
-#include "sta_info.h"
-#include "hostap_common.h"
-#include "hw_features.h"
-
-
-struct hostap_driver_data {
- struct hostapd_data *hapd;
-
- char iface[IFNAMSIZ + 1];
- int sock; /* raw packet socket for driver access */
- int ioctl_sock; /* socket for ioctl() use */
- int wext_sock; /* socket for wireless events */
-
- int we_version;
-
- u8 *generic_ie;
- size_t generic_ie_len;
- u8 *wps_ie;
- size_t wps_ie_len;
-};
-
-
-static int hostapd_ioctl(void *priv, struct prism2_hostapd_param *param,
- int len);
-static int hostap_set_iface_flags(void *priv, int dev_up);
-
-static void handle_data(struct hostapd_data *hapd, u8 *buf, size_t len,
- u16 stype)
-{
- struct ieee80211_hdr *hdr;
- u16 fc, ethertype;
- u8 *pos, *sa;
- size_t left;
- struct sta_info *sta;
-
- if (len < sizeof(struct ieee80211_hdr))
- return;
-
- hdr = (struct ieee80211_hdr *) buf;
- fc = le_to_host16(hdr->frame_control);
-
- if ((fc & (WLAN_FC_FROMDS | WLAN_FC_TODS)) != WLAN_FC_TODS) {
- printf("Not ToDS data frame (fc=0x%04x)\n", fc);
- return;
- }
-
- sa = hdr->addr2;
- sta = ap_get_sta(hapd, sa);
- if (!sta || !(sta->flags & WLAN_STA_ASSOC)) {
- printf("Data frame from not associated STA " MACSTR "\n",
- MAC2STR(sa));
- if (sta && (sta->flags & WLAN_STA_AUTH))
- hostapd_sta_disassoc(
- hapd, sa,
- WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
- else
- hostapd_sta_deauth(
- hapd, sa,
- WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
- return;
- }
-
- pos = (u8 *) (hdr + 1);
- left = len - sizeof(*hdr);
-
- if (left < sizeof(rfc1042_header)) {
- printf("Too short data frame\n");
- return;
- }
-
- if (memcmp(pos, rfc1042_header, sizeof(rfc1042_header)) != 0) {
- printf("Data frame with no RFC1042 header\n");
- return;
- }
- pos += sizeof(rfc1042_header);
- left -= sizeof(rfc1042_header);
-
- if (left < 2) {
- printf("No ethertype in data frame\n");
- return;
- }
-
- ethertype = WPA_GET_BE16(pos);
- pos += 2;
- left -= 2;
- switch (ethertype) {
- case ETH_P_PAE:
- ieee802_1x_receive(hapd, sa, pos, left);
- break;
-
- default:
- printf("Unknown ethertype 0x%04x in data frame\n", ethertype);
- break;
- }
-}
-
-
-static void handle_tx_callback(struct hostapd_data *hapd, u8 *buf, size_t len,
- int ok)
-{
- struct ieee80211_hdr *hdr;
- u16 fc, type, stype;
- struct sta_info *sta;
-
- hdr = (struct ieee80211_hdr *) buf;
- fc = le_to_host16(hdr->frame_control);
-
- type = WLAN_FC_GET_TYPE(fc);
- stype = WLAN_FC_GET_STYPE(fc);
-
- switch (type) {
- case WLAN_FC_TYPE_MGMT:
- wpa_printf(MSG_DEBUG, "MGMT (TX callback) %s",
- ok ? "ACK" : "fail");
- ieee802_11_mgmt_cb(hapd, buf, len, stype, ok);
- break;
- case WLAN_FC_TYPE_CTRL:
- wpa_printf(MSG_DEBUG, "CTRL (TX callback) %s",
- ok ? "ACK" : "fail");
- break;
- case WLAN_FC_TYPE_DATA:
- wpa_printf(MSG_DEBUG, "DATA (TX callback) %s",
- ok ? "ACK" : "fail");
- sta = ap_get_sta(hapd, hdr->addr1);
- if (sta && sta->flags & WLAN_STA_PENDING_POLL) {
- wpa_printf(MSG_DEBUG, "STA " MACSTR
- " %s pending activity poll",
- MAC2STR(sta->addr),
- ok ? "ACKed" : "did not ACK");
- if (ok)
- sta->flags &= ~WLAN_STA_PENDING_POLL;
- }
- if (sta)
- ieee802_1x_tx_status(hapd, sta, buf, len, ok);
- break;
- default:
- printf("unknown TX callback frame type %d\n", type);
- break;
- }
-}
-
-
-static void handle_frame(struct hostapd_data *hapd, u8 *buf, size_t len)
-{
- struct ieee80211_hdr *hdr;
- u16 fc, extra_len, type, stype;
- unsigned char *extra = NULL;
- size_t data_len = len;
- int ver;
-
- /* PSPOLL is only 16 bytes, but driver does not (at least yet) pass
- * these to user space */
- if (len < 24) {
- wpa_printf(MSG_MSGDUMP, "handle_frame: too short (%lu)",
- (unsigned long) len);
- return;
- }
-
- hdr = (struct ieee80211_hdr *) buf;
- fc = le_to_host16(hdr->frame_control);
- type = WLAN_FC_GET_TYPE(fc);
- stype = WLAN_FC_GET_STYPE(fc);
-
- if (type != WLAN_FC_TYPE_MGMT || stype != WLAN_FC_STYPE_BEACON) {
- wpa_hexdump(MSG_MSGDUMP, "Received management frame",
- buf, len);
- }
-
- ver = fc & WLAN_FC_PVER;
-
- /* protocol version 3 is reserved for indicating extra data after the
- * payload, version 2 for indicating ACKed frame (TX callbacks), and
- * version 1 for indicating failed frame (no ACK, TX callbacks) */
- if (ver == 3) {
- u8 *pos = buf + len - 2;
- extra_len = WPA_GET_LE16(pos);
- printf("extra data in frame (elen=%d)\n", extra_len);
- if ((size_t) extra_len + 2 > len) {
- printf(" extra data overflow\n");
- return;
- }
- len -= extra_len + 2;
- extra = buf + len;
- } else if (ver == 1 || ver == 2) {
- handle_tx_callback(hapd, buf, data_len, ver == 2 ? 1 : 0);
- return;
- } else if (ver != 0) {
- printf("unknown protocol version %d\n", ver);
- return;
- }
-
- switch (type) {
- case WLAN_FC_TYPE_MGMT:
- if (stype != WLAN_FC_STYPE_BEACON)
- wpa_printf(MSG_MSGDUMP, "MGMT");
- ieee802_11_mgmt(hapd, buf, data_len, stype, NULL);
- break;
- case WLAN_FC_TYPE_CTRL:
- wpa_printf(MSG_DEBUG, "CTRL");
- break;
- case WLAN_FC_TYPE_DATA:
- wpa_printf(MSG_DEBUG, "DATA");
- handle_data(hapd, buf, data_len, stype);
- break;
- default:
- wpa_printf(MSG_DEBUG, "unknown frame type %d", type);
- break;
- }
-}
-
-
-static void handle_read(int sock, void *eloop_ctx, void *sock_ctx)
-{
- struct hostapd_data *hapd = (struct hostapd_data *) eloop_ctx;
- int len;
- unsigned char buf[3000];
-
- len = recv(sock, buf, sizeof(buf), 0);
- if (len < 0) {
- perror("recv");
- return;
- }
-
- handle_frame(hapd, buf, len);
-}
-
-
-static int hostap_init_sockets(struct hostap_driver_data *drv)
-{
- struct ifreq ifr;
- struct sockaddr_ll addr;
-
- drv->sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
- if (drv->sock < 0) {
- perror("socket[PF_PACKET,SOCK_RAW]");
- return -1;
- }
-
- if (eloop_register_read_sock(drv->sock, handle_read, drv->hapd, NULL))
- {
- printf("Could not register read socket\n");
- return -1;
- }
-
- memset(&ifr, 0, sizeof(ifr));
- snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%sap", drv->iface);
- if (ioctl(drv->sock, SIOCGIFINDEX, &ifr) != 0) {
- perror("ioctl(SIOCGIFINDEX)");
- return -1;
- }
-
- if (hostap_set_iface_flags(drv, 1)) {
- return -1;
- }
-
- memset(&addr, 0, sizeof(addr));
- addr.sll_family = AF_PACKET;
- addr.sll_ifindex = ifr.ifr_ifindex;
- wpa_printf(MSG_DEBUG, "Opening raw packet socket for ifindex %d",
- addr.sll_ifindex);
-
- if (bind(drv->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
- perror("bind");
- return -1;
- }
-
- memset(&ifr, 0, sizeof(ifr));
- os_strlcpy(ifr.ifr_name, drv->iface, sizeof(ifr.ifr_name));
- if (ioctl(drv->sock, SIOCGIFHWADDR, &ifr) != 0) {
- perror("ioctl(SIOCGIFHWADDR)");
- return -1;
- }
-
- if (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) {
- printf("Invalid HW-addr family 0x%04x\n",
- ifr.ifr_hwaddr.sa_family);
- return -1;
- }
- memcpy(drv->hapd->own_addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
-
- return 0;
-}
-
-
-static int hostap_send_mgmt_frame(void *priv, const void *msg, size_t len,
- int flags)
-{
- struct hostap_driver_data *drv = priv;
- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) msg;
- int res;
-
- /* Request TX callback */
- hdr->frame_control |= host_to_le16(BIT(1));
- res = send(drv->sock, msg, len, flags);
- hdr->frame_control &= ~host_to_le16(BIT(1));
-
- return res;
-}
-
-
-static int hostap_send_eapol(void *priv, const u8 *addr, const u8 *data,
- size_t data_len, int encrypt, const u8 *own_addr)
-{
- struct hostap_driver_data *drv = priv;
- struct ieee80211_hdr *hdr;
- size_t len;
- u8 *pos;
- int res;
-
- len = sizeof(*hdr) + sizeof(rfc1042_header) + 2 + data_len;
- hdr = os_zalloc(len);
- if (hdr == NULL) {
- printf("malloc() failed for hostapd_send_data(len=%lu)\n",
- (unsigned long) len);
- return -1;
- }
-
- hdr->frame_control =
- IEEE80211_FC(WLAN_FC_TYPE_DATA, WLAN_FC_STYPE_DATA);
- hdr->frame_control |= host_to_le16(WLAN_FC_FROMDS);
- if (encrypt)
- hdr->frame_control |= host_to_le16(WLAN_FC_ISWEP);
- memcpy(hdr->IEEE80211_DA_FROMDS, addr, ETH_ALEN);
- memcpy(hdr->IEEE80211_BSSID_FROMDS, own_addr, ETH_ALEN);
- memcpy(hdr->IEEE80211_SA_FROMDS, own_addr, ETH_ALEN);
-
- pos = (u8 *) (hdr + 1);
- memcpy(pos, rfc1042_header, sizeof(rfc1042_header));
- pos += sizeof(rfc1042_header);
- *((u16 *) pos) = htons(ETH_P_PAE);
- pos += 2;
- memcpy(pos, data, data_len);
-
- res = hostap_send_mgmt_frame(drv, (u8 *) hdr, len, 0);
- free(hdr);
-
- if (res < 0) {
- perror("hostapd_send_eapol: send");
- printf("hostapd_send_eapol - packet len: %lu - failed\n",
- (unsigned long) len);
- }
-
- return res;
-}
-
-
-static int hostap_sta_set_flags(void *priv, const u8 *addr,
- int total_flags, int flags_or, int flags_and)
-{
- struct hostap_driver_data *drv = priv;
- struct prism2_hostapd_param param;
-
- memset(&param, 0, sizeof(param));
- param.cmd = PRISM2_HOSTAPD_SET_FLAGS_STA;
- memcpy(param.sta_addr, addr, ETH_ALEN);
- param.u.set_flags_sta.flags_or = flags_or;
- param.u.set_flags_sta.flags_and = flags_and;
- return hostapd_ioctl(drv, &param, sizeof(param));
-}
-
-
-static int hostap_set_iface_flags(void *priv, int dev_up)
-{
- struct hostap_driver_data *drv = priv;
- struct ifreq ifr;
-
- if (drv->ioctl_sock < 0)
- return -1;
-
- memset(&ifr, 0, sizeof(ifr));
- snprintf(ifr.ifr_name, IFNAMSIZ, "%sap", drv->iface);
-
- if (ioctl(drv->ioctl_sock, SIOCGIFFLAGS, &ifr) != 0) {
- perror("ioctl[SIOCGIFFLAGS]");
- return -1;
- }
-
- if (dev_up)
- ifr.ifr_flags |= IFF_UP;
- else
- ifr.ifr_flags &= ~IFF_UP;
-
- if (ioctl(drv->ioctl_sock, SIOCSIFFLAGS, &ifr) != 0) {
- perror("ioctl[SIOCSIFFLAGS]");
- return -1;
- }
-
- if (dev_up) {
- memset(&ifr, 0, sizeof(ifr));
- snprintf(ifr.ifr_name, IFNAMSIZ, "%sap", drv->iface);
- ifr.ifr_mtu = HOSTAPD_MTU;
- if (ioctl(drv->ioctl_sock, SIOCSIFMTU, &ifr) != 0) {
- perror("ioctl[SIOCSIFMTU]");
- printf("Setting MTU failed - trying to survive with "
- "current value\n");
- }
- }
-
- return 0;
-}
-
-
-static int hostapd_ioctl(void *priv, struct prism2_hostapd_param *param,
- int len)
-{
- struct hostap_driver_data *drv = priv;
- struct iwreq iwr;
-
- memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
- iwr.u.data.pointer = (caddr_t) param;
- iwr.u.data.length = len;
-
- if (ioctl(drv->ioctl_sock, PRISM2_IOCTL_HOSTAPD, &iwr) < 0) {
- perror("ioctl[PRISM2_IOCTL_HOSTAPD]");
- return -1;
- }
-
- return 0;
-}
-
-
-static int hostap_set_encryption(const char *ifname, void *priv,
- const char *alg, const u8 *addr,
- int idx, const u8 *key, size_t key_len,
- int txkey)
-{
- struct hostap_driver_data *drv = priv;
- struct prism2_hostapd_param *param;
- u8 *buf;
- size_t blen;
- int ret = 0;
-
- blen = sizeof(*param) + key_len;
- buf = os_zalloc(blen);
- if (buf == NULL)
- return -1;
-
- param = (struct prism2_hostapd_param *) buf;
- param->cmd = PRISM2_SET_ENCRYPTION;
- if (addr == NULL)
- memset(param->sta_addr, 0xff, ETH_ALEN);
- else
- memcpy(param->sta_addr, addr, ETH_ALEN);
- os_strlcpy((char *) param->u.crypt.alg, alg,
- HOSTAP_CRYPT_ALG_NAME_LEN);
- param->u.crypt.flags = txkey ? HOSTAP_CRYPT_FLAG_SET_TX_KEY : 0;
- param->u.crypt.idx = idx;
- param->u.crypt.key_len = key_len;
- memcpy((u8 *) (param + 1), key, key_len);
-
- if (hostapd_ioctl(drv, param, blen)) {
- printf("Failed to set encryption.\n");
- ret = -1;
- }
- free(buf);
-
- return ret;
-}
-
-
-static int hostap_get_seqnum(const char *ifname, void *priv, const u8 *addr,
- int idx, u8 *seq)
-{
- struct hostap_driver_data *drv = priv;
- struct prism2_hostapd_param *param;
- u8 *buf;
- size_t blen;
- int ret = 0;
-
- blen = sizeof(*param) + 32;
- buf = os_zalloc(blen);
- if (buf == NULL)
- return -1;
-
- param = (struct prism2_hostapd_param *) buf;
- param->cmd = PRISM2_GET_ENCRYPTION;
- if (addr == NULL)
- memset(param->sta_addr, 0xff, ETH_ALEN);
- else
- memcpy(param->sta_addr, addr, ETH_ALEN);
- param->u.crypt.idx = idx;
-
- if (hostapd_ioctl(drv, param, blen)) {
- printf("Failed to get encryption.\n");
- ret = -1;
- } else {
- memcpy(seq, param->u.crypt.seq, 8);
- }
- free(buf);
-
- return ret;
-}
-
-
-static int hostap_ioctl_prism2param(void *priv, int param, int value)
-{
- struct hostap_driver_data *drv = priv;
- struct iwreq iwr;
- int *i;
-
- memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
- i = (int *) iwr.u.name;
- *i++ = param;
- *i++ = value;
-
- if (ioctl(drv->ioctl_sock, PRISM2_IOCTL_PRISM2_PARAM, &iwr) < 0) {
- perror("ioctl[PRISM2_IOCTL_PRISM2_PARAM]");
- return -1;
- }
-
- return 0;
-}
-
-
-static int hostap_set_ieee8021x(const char *ifname, void *priv, int enabled)
-{
- struct hostap_driver_data *drv = priv;
-
- /* enable kernel driver support for IEEE 802.1X */
- if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_IEEE_802_1X, enabled)) {
- printf("Could not setup IEEE 802.1X support in kernel driver."
- "\n");
- return -1;
- }
-
- if (!enabled)
- return 0;
-
- /* use host driver implementation of encryption to allow
- * individual keys and passing plaintext EAPOL frames */
- if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOST_DECRYPT, 1) ||
- hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOST_ENCRYPT, 1)) {
- printf("Could not setup host-based encryption in kernel "
- "driver.\n");
- return -1;
- }
-
- return 0;
-}
-
-
-static int hostap_set_privacy(const char *ifname, void *priv, int enabled)
-{
- struct hostap_drvier_data *drv = priv;
-
- return hostap_ioctl_prism2param(drv, PRISM2_PARAM_PRIVACY_INVOKED,
- enabled);
-}
-
-
-static int hostap_set_ssid(const char *ifname, void *priv, const u8 *buf,
- int len)
-{
- struct hostap_driver_data *drv = priv;
- struct iwreq iwr;
-
- memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
- iwr.u.essid.flags = 1; /* SSID active */
- iwr.u.essid.pointer = (caddr_t) buf;
- iwr.u.essid.length = len + 1;
-
- if (ioctl(drv->ioctl_sock, SIOCSIWESSID, &iwr) < 0) {
- perror("ioctl[SIOCSIWESSID]");
- printf("len=%d\n", len);
- return -1;
- }
-
- return 0;
-}
-
-
-static int hostap_flush(void *priv)
-{
- struct hostap_driver_data *drv = priv;
- struct prism2_hostapd_param param;
-
- memset(&param, 0, sizeof(param));
- param.cmd = PRISM2_HOSTAPD_FLUSH;
- return hostapd_ioctl(drv, &param, sizeof(param));
-}
-
-
-static int hostap_read_sta_data(void *priv,
- struct hostap_sta_driver_data *data,
- const u8 *addr)
-{
- struct hostap_driver_data *drv = priv;
- char buf[1024], line[128], *pos;
- FILE *f;
- unsigned long val;
-
- memset(data, 0, sizeof(*data));
- snprintf(buf, sizeof(buf), "/proc/net/hostap/%s/" MACSTR,
- drv->iface, MAC2STR(addr));
-
- f = fopen(buf, "r");
- if (!f)
- return -1;
- /* Need to read proc file with in one piece, so use large enough
- * buffer. */
- setbuffer(f, buf, sizeof(buf));
-
- while (fgets(line, sizeof(line), f)) {
- pos = strchr(line, '=');
- if (!pos)
- continue;
- *pos++ = '\0';
- val = strtoul(pos, NULL, 10);
- if (strcmp(line, "rx_packets") == 0)
- data->rx_packets = val;
- else if (strcmp(line, "tx_packets") == 0)
- data->tx_packets = val;
- else if (strcmp(line, "rx_bytes") == 0)
- data->rx_bytes = val;
- else if (strcmp(line, "tx_bytes") == 0)
- data->tx_bytes = val;
- }
-
- fclose(f);
-
- return 0;
-}
-
-
-static int hostap_sta_add(const char *ifname, void *priv, const u8 *addr,
- u16 aid, u16 capability, u8 *supp_rates,
- size_t supp_rates_len, int flags,
- u16 listen_interval)
-{
- struct hostap_driver_data *drv = priv;
- struct prism2_hostapd_param param;
- int tx_supp_rates = 0;
- size_t i;
-
-#define WLAN_RATE_1M BIT(0)
-#define WLAN_RATE_2M BIT(1)
-#define WLAN_RATE_5M5 BIT(2)
-#define WLAN_RATE_11M BIT(3)
-
- for (i = 0; i < supp_rates_len; i++) {
- if ((supp_rates[i] & 0x7f) == 2)
- tx_supp_rates |= WLAN_RATE_1M;
- if ((supp_rates[i] & 0x7f) == 4)
- tx_supp_rates |= WLAN_RATE_2M;
- if ((supp_rates[i] & 0x7f) == 11)
- tx_supp_rates |= WLAN_RATE_5M5;
- if ((supp_rates[i] & 0x7f) == 22)
- tx_supp_rates |= WLAN_RATE_11M;
- }
-
- memset(&param, 0, sizeof(param));
- param.cmd = PRISM2_HOSTAPD_ADD_STA;
- memcpy(param.sta_addr, addr, ETH_ALEN);
- param.u.add_sta.aid = aid;
- param.u.add_sta.capability = capability;
- param.u.add_sta.tx_supp_rates = tx_supp_rates;
- return hostapd_ioctl(drv, &param, sizeof(param));
-}
-
-
-static int hostap_sta_remove(void *priv, const u8 *addr)
-{
- struct hostap_driver_data *drv = priv;
- struct prism2_hostapd_param param;
-
- hostap_sta_set_flags(drv, addr, 0, 0, ~WLAN_STA_AUTHORIZED);
-
- memset(&param, 0, sizeof(param));
- param.cmd = PRISM2_HOSTAPD_REMOVE_STA;
- memcpy(param.sta_addr, addr, ETH_ALEN);
- if (hostapd_ioctl(drv, &param, sizeof(param))) {
- printf("Could not remove station from kernel driver.\n");
- return -1;
- }
- return 0;
-}
-
-
-static int hostap_get_inact_sec(void *priv, const u8 *addr)
-{
- struct hostap_driver_data *drv = priv;
- struct prism2_hostapd_param param;
-
- memset(&param, 0, sizeof(param));
- param.cmd = PRISM2_HOSTAPD_GET_INFO_STA;
- memcpy(param.sta_addr, addr, ETH_ALEN);
- if (hostapd_ioctl(drv, &param, sizeof(param))) {
- return -1;
- }
-
- return param.u.get_info_sta.inactive_sec;
-}
-
-
-static int hostap_sta_clear_stats(void *priv, const u8 *addr)
-{
- struct hostap_driver_data *drv = priv;
- struct prism2_hostapd_param param;
-
- memset(&param, 0, sizeof(param));
- param.cmd = PRISM2_HOSTAPD_STA_CLEAR_STATS;
- memcpy(param.sta_addr, addr, ETH_ALEN);
- if (hostapd_ioctl(drv, &param, sizeof(param))) {
- return -1;
- }
-
- return 0;
-}
-
-
-static int hostap_set_assoc_ap(void *priv, const u8 *addr)
-{
- struct hostap_driver_data *drv = priv;
- struct prism2_hostapd_param param;
-
- memset(&param, 0, sizeof(param));
- param.cmd = PRISM2_HOSTAPD_SET_ASSOC_AP_ADDR;
- memcpy(param.sta_addr, addr, ETH_ALEN);
- if (hostapd_ioctl(drv, &param, sizeof(param)))
- return -1;
-
- return 0;
-}
-
-
-static int hostapd_ioctl_set_generic_elem(struct hostap_driver_data *drv)
-{
- struct prism2_hostapd_param *param;
- int res;
- size_t blen, elem_len;
-
- elem_len = drv->generic_ie_len + drv->wps_ie_len;
- blen = PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN + elem_len;
- if (blen < sizeof(*param))
- blen = sizeof(*param);
-
- param = os_zalloc(blen);
- if (param == NULL)
- return -1;
-
- param->cmd = PRISM2_HOSTAPD_SET_GENERIC_ELEMENT;
- param->u.generic_elem.len = elem_len;
- if (drv->generic_ie) {
- os_memcpy(param->u.generic_elem.data, drv->generic_ie,
- drv->generic_ie_len);
- }
- if (drv->wps_ie) {
- os_memcpy(&param->u.generic_elem.data[drv->generic_ie_len],
- drv->wps_ie, drv->wps_ie_len);
- }
- wpa_hexdump(MSG_DEBUG, "hostap: Set generic IE",
- param->u.generic_elem.data, elem_len);
- res = hostapd_ioctl(drv, param, blen);
-
- os_free(param);
-
- return res;
-}
-
-
-static int hostap_set_generic_elem(const char *ifname, void *priv,
- const u8 *elem, size_t elem_len)
-{
- struct hostap_driver_data *drv = priv;
-
- os_free(drv->generic_ie);
- drv->generic_ie = NULL;
- drv->generic_ie_len = 0;
- if (elem) {
- drv->generic_ie = os_malloc(elem_len);
- if (drv->generic_ie == NULL)
- return -1;
- os_memcpy(drv->generic_ie, elem, elem_len);
- drv->generic_ie_len = elem_len;
- }
-
- return hostapd_ioctl_set_generic_elem(drv);
-}
-
-
-static int hostap_set_wps_beacon_ie(const char *ifname, void *priv,
- const u8 *ie, size_t len)
-{
- /* Host AP driver supports only one set of extra IEs, so we need to
- * use the ProbeResp IEs also for Beacon frames since they include more
- * information. */
- return 0;
-}
-
-
-static int hostap_set_wps_probe_resp_ie(const char *ifname, void *priv,
- const u8 *ie, size_t len)
-{
- struct hostap_driver_data *drv = priv;
-
- os_free(drv->wps_ie);
- drv->wps_ie = NULL;
- drv->wps_ie_len = 0;
- if (ie) {
- drv->wps_ie = os_malloc(len);
- if (drv->wps_ie == NULL)
- return -1;
- os_memcpy(drv->wps_ie, ie, len);
- drv->wps_ie_len = len;
- }
-
- return hostapd_ioctl_set_generic_elem(drv);
-}
-
-
-static void
-hostapd_wireless_event_wireless_custom(struct hostap_driver_data *drv,
- char *custom)
-{
- wpa_printf(MSG_DEBUG, "Custom wireless event: '%s'", custom);
-
- if (strncmp(custom, "MLME-MICHAELMICFAILURE.indication", 33) == 0) {
- char *pos;
- u8 addr[ETH_ALEN];
- pos = strstr(custom, "addr=");
- if (pos == NULL) {
- wpa_printf(MSG_DEBUG,
- "MLME-MICHAELMICFAILURE.indication "
- "without sender address ignored");
- return;
- }
- pos += 5;
- if (hwaddr_aton(pos, addr) == 0) {
- ieee80211_michael_mic_failure(drv->hapd, addr, 1);
- } else {
- wpa_printf(MSG_DEBUG,
- "MLME-MICHAELMICFAILURE.indication "
- "with invalid MAC address");
- }
- }
-}
-
-
-static void hostapd_wireless_event_wireless(struct hostap_driver_data *drv,
- char *data, int len)
-{
- struct iw_event iwe_buf, *iwe = &iwe_buf;
- char *pos, *end, *custom, *buf;
-
- pos = data;
- end = data + len;
-
- while (pos + IW_EV_LCP_LEN <= end) {
- /* Event data may be unaligned, so make a local, aligned copy
- * before processing. */
- memcpy(&iwe_buf, pos, IW_EV_LCP_LEN);
- wpa_printf(MSG_DEBUG, "Wireless event: cmd=0x%x len=%d",
- iwe->cmd, iwe->len);
- if (iwe->len <= IW_EV_LCP_LEN)
- return;
-
- custom = pos + IW_EV_POINT_LEN;
- if (drv->we_version > 18 &&
- (iwe->cmd == IWEVMICHAELMICFAILURE ||
- iwe->cmd == IWEVCUSTOM)) {
- /* WE-19 removed the pointer from struct iw_point */
- char *dpos = (char *) &iwe_buf.u.data.length;
- int dlen = dpos - (char *) &iwe_buf;
- memcpy(dpos, pos + IW_EV_LCP_LEN,
- sizeof(struct iw_event) - dlen);
- } else {
- memcpy(&iwe_buf, pos, sizeof(struct iw_event));
- custom += IW_EV_POINT_OFF;
- }
-
- switch (iwe->cmd) {
- case IWEVCUSTOM:
- if (custom + iwe->u.data.length > end)
- return;
- buf = malloc(iwe->u.data.length + 1);
- if (buf == NULL)
- return;
- memcpy(buf, custom, iwe->u.data.length);
- buf[iwe->u.data.length] = '\0';
- hostapd_wireless_event_wireless_custom(drv, buf);
- free(buf);
- break;
- }
-
- pos += iwe->len;
- }
-}
-
-
-static void hostapd_wireless_event_rtm_newlink(struct hostap_driver_data *drv,
- struct nlmsghdr *h, int len)
-{
- struct ifinfomsg *ifi;
- int attrlen, nlmsg_len, rta_len;
- struct rtattr * attr;
-
- if (len < (int) sizeof(*ifi))
- return;
-
- ifi = NLMSG_DATA(h);
-
- /* TODO: use ifi->ifi_index to filter out wireless events from other
- * interfaces */
-
- nlmsg_len = NLMSG_ALIGN(sizeof(struct ifinfomsg));
-
- attrlen = h->nlmsg_len - nlmsg_len;
- if (attrlen < 0)
- return;
-
- attr = (struct rtattr *) (((char *) ifi) + nlmsg_len);
-
- rta_len = RTA_ALIGN(sizeof(struct rtattr));
- while (RTA_OK(attr, attrlen)) {
- if (attr->rta_type == IFLA_WIRELESS) {
- hostapd_wireless_event_wireless(
- drv, ((char *) attr) + rta_len,
- attr->rta_len - rta_len);
- }
- attr = RTA_NEXT(attr, attrlen);
- }
-}
-
-
-static void hostapd_wireless_event_receive(int sock, void *eloop_ctx,
- void *sock_ctx)
-{
- char buf[256];
- int left;
- struct sockaddr_nl from;
- socklen_t fromlen;
- struct nlmsghdr *h;
- struct hostap_driver_data *drv = eloop_ctx;
-
- fromlen = sizeof(from);
- left = recvfrom(sock, buf, sizeof(buf), MSG_DONTWAIT,
- (struct sockaddr *) &from, &fromlen);
- if (left < 0) {
- if (errno != EINTR && errno != EAGAIN)
- perror("recvfrom(netlink)");
- return;
- }
-
- h = (struct nlmsghdr *) buf;
- while (left >= (int) sizeof(*h)) {
- int len, plen;
-
- len = h->nlmsg_len;
- plen = len - sizeof(*h);
- if (len > left || plen < 0) {
- printf("Malformed netlink message: "
- "len=%d left=%d plen=%d\n",
- len, left, plen);
- break;
- }
-
- switch (h->nlmsg_type) {
- case RTM_NEWLINK:
- hostapd_wireless_event_rtm_newlink(drv, h, plen);
- break;
- }
-
- len = NLMSG_ALIGN(len);
- left -= len;
- h = (struct nlmsghdr *) ((char *) h + len);
- }
-
- if (left > 0) {
- printf("%d extra bytes in the end of netlink message\n", left);
- }
-}
-
-
-static int hostap_get_we_version(struct hostap_driver_data *drv)
-{
- struct iw_range *range;
- struct iwreq iwr;
- int minlen;
- size_t buflen;
-
- drv->we_version = 0;
-
- /*
- * Use larger buffer than struct iw_range in order to allow the
- * structure to grow in the future.
- */
- buflen = sizeof(struct iw_range) + 500;
- range = os_zalloc(buflen);
- if (range == NULL)
- return -1;
-
- memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
- iwr.u.data.pointer = (caddr_t) range;
- iwr.u.data.length = buflen;
-
- minlen = ((char *) &range->enc_capa) - (char *) range +
- sizeof(range->enc_capa);
-
- if (ioctl(drv->ioctl_sock, SIOCGIWRANGE, &iwr) < 0) {
- perror("ioctl[SIOCGIWRANGE]");
- free(range);
- return -1;
- } else if (iwr.u.data.length >= minlen &&
- range->we_version_compiled >= 18) {
- wpa_printf(MSG_DEBUG, "SIOCGIWRANGE: WE(compiled)=%d "
- "WE(source)=%d enc_capa=0x%x",
- range->we_version_compiled,
- range->we_version_source,
- range->enc_capa);
- drv->we_version = range->we_version_compiled;
- }
-
- free(range);
- return 0;
-}
-
-
-static int hostap_wireless_event_init(void *priv)
-{
- struct hostap_driver_data *drv = priv;
- int s;
- struct sockaddr_nl local;
-
- hostap_get_we_version(drv);
-
- drv->wext_sock = -1;
-
- s = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
- if (s < 0) {
- perror("socket(PF_NETLINK,SOCK_RAW,NETLINK_ROUTE)");
- return -1;
- }
-
- memset(&local, 0, sizeof(local));
- local.nl_family = AF_NETLINK;
- local.nl_groups = RTMGRP_LINK;
- if (bind(s, (struct sockaddr *) &local, sizeof(local)) < 0) {
- perror("bind(netlink)");
- close(s);
- return -1;
- }
-
- eloop_register_read_sock(s, hostapd_wireless_event_receive, drv,
- NULL);
- drv->wext_sock = s;
-
- return 0;
-}
-
-
-static void hostap_wireless_event_deinit(void *priv)
-{
- struct hostap_driver_data *drv = priv;
- if (drv->wext_sock < 0)
- return;
- eloop_unregister_read_sock(drv->wext_sock);
- close(drv->wext_sock);
-}
-
-
-static void * hostap_init(struct hostapd_data *hapd)
-{
- struct hostap_driver_data *drv;
-
- drv = os_zalloc(sizeof(struct hostap_driver_data));
- if (drv == NULL) {
- printf("Could not allocate memory for hostapd driver data\n");
- return NULL;
- }
-
- drv->hapd = hapd;
- drv->ioctl_sock = drv->sock = -1;
- memcpy(drv->iface, hapd->conf->iface, sizeof(drv->iface));
-
- drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
- if (drv->ioctl_sock < 0) {
- perror("socket[PF_INET,SOCK_DGRAM]");
- free(drv);
- return NULL;
- }
-
- if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD, 1)) {
- printf("Could not enable hostapd mode for interface %s\n",
- drv->iface);
- close(drv->ioctl_sock);
- free(drv);
- return NULL;
- }
-
- if (hostap_init_sockets(drv)) {
- close(drv->ioctl_sock);
- free(drv);
- return NULL;
- }
-
- return drv;
-}
-
-
-static void hostap_driver_deinit(void *priv)
-{
- struct hostap_driver_data *drv = priv;
-
- (void) hostap_set_iface_flags(drv, 0);
- (void) hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD, 0);
- (void) hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD_STA, 0);
-
- if (drv->ioctl_sock >= 0)
- close(drv->ioctl_sock);
-
- if (drv->sock >= 0)
- close(drv->sock);
-
- os_free(drv->generic_ie);
- os_free(drv->wps_ie);
-
- free(drv);
-}
-
-
-static int hostap_sta_deauth(void *priv, const u8 *addr, int reason)
-{
- struct hostap_driver_data *drv = priv;
- struct ieee80211_mgmt mgmt;
-
- memset(&mgmt, 0, sizeof(mgmt));
- mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
- WLAN_FC_STYPE_DEAUTH);
- memcpy(mgmt.da, addr, ETH_ALEN);
- memcpy(mgmt.sa, drv->hapd->own_addr, ETH_ALEN);
- memcpy(mgmt.bssid, drv->hapd->own_addr, ETH_ALEN);
- mgmt.u.deauth.reason_code = host_to_le16(reason);
- return hostap_send_mgmt_frame(drv, &mgmt, IEEE80211_HDRLEN +
- sizeof(mgmt.u.deauth), 0);
-}
-
-
-static int hostap_sta_disassoc(void *priv, const u8 *addr, int reason)
-{
- struct hostap_driver_data *drv = priv;
- struct ieee80211_mgmt mgmt;
-
- memset(&mgmt, 0, sizeof(mgmt));
- mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
- WLAN_FC_STYPE_DISASSOC);
- memcpy(mgmt.da, addr, ETH_ALEN);
- memcpy(mgmt.sa, drv->hapd->own_addr, ETH_ALEN);
- memcpy(mgmt.bssid, drv->hapd->own_addr, ETH_ALEN);
- mgmt.u.disassoc.reason_code = host_to_le16(reason);
- return hostap_send_mgmt_frame(drv, &mgmt, IEEE80211_HDRLEN +
- sizeof(mgmt.u.disassoc), 0);
-}
-
-
-static struct hostapd_hw_modes * hostap_get_hw_feature_data(void *priv,
- u16 *num_modes,
- u16 *flags)
-{
- struct hostapd_hw_modes *mode;
- int i, clen, rlen;
- const short chan2freq[14] = {
- 2412, 2417, 2422, 2427, 2432, 2437, 2442,
- 2447, 2452, 2457, 2462, 2467, 2472, 2484
- };
-
- mode = os_zalloc(sizeof(struct hostapd_hw_modes));
- if (mode == NULL)
- return NULL;
-
- *num_modes = 1;
- *flags = 0;
-
- mode->mode = HOSTAPD_MODE_IEEE80211B;
- mode->num_channels = 14;
- mode->num_rates = 4;
-
- clen = mode->num_channels * sizeof(struct hostapd_channel_data);
- rlen = mode->num_rates * sizeof(struct hostapd_rate_data);
-
- mode->channels = os_zalloc(clen);
- mode->rates = os_zalloc(rlen);
- if (mode->channels == NULL || mode->rates == NULL) {
- hostapd_free_hw_features(mode, *num_modes);
- return NULL;
- }
-
- for (i = 0; i < 14; i++) {
- mode->channels[i].chan = i + 1;
- mode->channels[i].freq = chan2freq[i];
- /* TODO: Get allowed channel list from the driver */
- if (i >= 11)
- mode->channels[i].flag = HOSTAPD_CHAN_DISABLED;
- }
-
- mode->rates[0].rate = 10;
- mode->rates[0].flags = HOSTAPD_RATE_CCK;
- mode->rates[1].rate = 20;
- mode->rates[1].flags = HOSTAPD_RATE_CCK;
- mode->rates[2].rate = 55;
- mode->rates[2].flags = HOSTAPD_RATE_CCK;
- mode->rates[3].rate = 110;
- mode->rates[3].flags = HOSTAPD_RATE_CCK;
-
- return mode;
-}
-
-
-const struct wpa_driver_ops wpa_driver_hostap_ops = {
- .name = "hostap",
- .init = hostap_init,
- .deinit = hostap_driver_deinit,
- .wireless_event_init = hostap_wireless_event_init,
- .wireless_event_deinit = hostap_wireless_event_deinit,
- .set_ieee8021x = hostap_set_ieee8021x,
- .set_privacy = hostap_set_privacy,
- .set_encryption = hostap_set_encryption,
- .get_seqnum = hostap_get_seqnum,
- .flush = hostap_flush,
- .set_generic_elem = hostap_set_generic_elem,
- .read_sta_data = hostap_read_sta_data,
- .send_eapol = hostap_send_eapol,
- .sta_set_flags = hostap_sta_set_flags,
- .sta_deauth = hostap_sta_deauth,
- .sta_disassoc = hostap_sta_disassoc,
- .sta_remove = hostap_sta_remove,
- .set_ssid = hostap_set_ssid,
- .send_mgmt_frame = hostap_send_mgmt_frame,
- .set_assoc_ap = hostap_set_assoc_ap,
- .sta_add = hostap_sta_add,
- .get_inact_sec = hostap_get_inact_sec,
- .sta_clear_stats = hostap_sta_clear_stats,
- .get_hw_feature_data = hostap_get_hw_feature_data,
- .set_wps_beacon_ie = hostap_set_wps_beacon_ie,
- .set_wps_probe_resp_ie = hostap_set_wps_probe_resp_ie,
-};
diff --git a/hostapd/driver_madwifi.c b/hostapd/driver_madwifi.c
deleted file mode 100644
index 4083fda29b23..000000000000
--- a/hostapd/driver_madwifi.c
+++ /dev/null
@@ -1,1483 +0,0 @@
-/*
- * hostapd / Driver interaction with MADWIFI 802.11 driver
- * Copyright (c) 2004, Sam Leffler <sam@errno.com>
- * Copyright (c) 2004, Video54 Technologies
- * Copyright (c) 2005-2007, Jouni Malinen <j@w1.fi>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Alternatively, this software may be distributed under the terms of BSD
- * license.
- *
- * See README and COPYING for more details.
- */
-
-#include "includes.h"
-#include <net/if.h>
-#include <sys/ioctl.h>
-
-#include <include/compat.h>
-#include <net80211/ieee80211.h>
-#ifdef WME_NUM_AC
-/* Assume this is built against BSD branch of madwifi driver. */
-#define MADWIFI_BSD
-#include <net80211/_ieee80211.h>
-#endif /* WME_NUM_AC */
-#include <net80211/ieee80211_crypto.h>
-#include <net80211/ieee80211_ioctl.h>
-
-#ifdef CONFIG_WPS
-#ifdef IEEE80211_IOCTL_FILTERFRAME
-#include <netpacket/packet.h>
-
-#ifndef ETH_P_80211_RAW
-#define ETH_P_80211_RAW 0x0019
-#endif
-#endif /* IEEE80211_IOCTL_FILTERFRAME */
-#endif /* CONFIG_WPS */
-
-/*
- * Avoid conflicts with hostapd definitions by undefining couple of defines
- * from madwifi header files.
- */
-#undef RSN_VERSION
-#undef WPA_VERSION
-#undef WPA_OUI_TYPE
-#undef WME_OUI_TYPE
-
-
-#ifdef IEEE80211_IOCTL_SETWMMPARAMS
-/* Assume this is built against madwifi-ng */
-#define MADWIFI_NG
-#endif /* IEEE80211_IOCTL_SETWMMPARAMS */
-
-#include "wireless_copy.h"
-
-#include "hostapd.h"
-#include "driver.h"
-#include "ieee802_1x.h"
-#include "eloop.h"
-#include "priv_netlink.h"
-#include "sta_info.h"
-#include "l2_packet/l2_packet.h"
-
-#include "wpa.h"
-#include "radius/radius.h"
-#include "ieee802_11.h"
-#include "accounting.h"
-#include "common.h"
-#include "wps_hostapd.h"
-
-
-struct madwifi_driver_data {
- struct hostapd_data *hapd; /* back pointer */
-
- char iface[IFNAMSIZ + 1];
- int ifindex;
- struct l2_packet_data *sock_xmit; /* raw packet xmit socket */
- struct l2_packet_data *sock_recv; /* raw packet recv socket */
- int ioctl_sock; /* socket for ioctl() use */
- int wext_sock; /* socket for wireless events */
- int we_version;
- u8 acct_mac[ETH_ALEN];
- struct hostap_sta_driver_data acct_data;
-
- struct l2_packet_data *sock_raw; /* raw 802.11 management frames */
-};
-
-static int madwifi_sta_deauth(void *priv, const u8 *addr, int reason_code);
-
-static int
-set80211priv(struct madwifi_driver_data *drv, int op, void *data, int len)
-{
- struct iwreq iwr;
- int do_inline = len < IFNAMSIZ;
-
- memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
-#ifdef IEEE80211_IOCTL_FILTERFRAME
- /* FILTERFRAME must be NOT inline, regardless of size. */
- if (op == IEEE80211_IOCTL_FILTERFRAME)
- do_inline = 0;
-#endif /* IEEE80211_IOCTL_FILTERFRAME */
- if (op == IEEE80211_IOCTL_SET_APPIEBUF)
- do_inline = 0;
- if (do_inline) {
- /*
- * Argument data fits inline; put it there.
- */
- memcpy(iwr.u.name, data, len);
- } else {
- /*
- * Argument data too big for inline transfer; setup a
- * parameter block instead; the kernel will transfer
- * the data for the driver.
- */
- iwr.u.data.pointer = data;
- iwr.u.data.length = len;
- }
-
- if (ioctl(drv->ioctl_sock, op, &iwr) < 0) {
-#ifdef MADWIFI_NG
- int first = IEEE80211_IOCTL_SETPARAM;
- static const char *opnames[] = {
- "ioctl[IEEE80211_IOCTL_SETPARAM]",
- "ioctl[IEEE80211_IOCTL_GETPARAM]",
- "ioctl[IEEE80211_IOCTL_SETMODE]",
- "ioctl[IEEE80211_IOCTL_GETMODE]",
- "ioctl[IEEE80211_IOCTL_SETWMMPARAMS]",
- "ioctl[IEEE80211_IOCTL_GETWMMPARAMS]",
- "ioctl[IEEE80211_IOCTL_SETCHANLIST]",
- "ioctl[IEEE80211_IOCTL_GETCHANLIST]",
- "ioctl[IEEE80211_IOCTL_CHANSWITCH]",
- "ioctl[IEEE80211_IOCTL_GET_APPIEBUF]",
- "ioctl[IEEE80211_IOCTL_SET_APPIEBUF]",
- "ioctl[IEEE80211_IOCTL_GETSCANRESULTS]",
- "ioctl[IEEE80211_IOCTL_FILTERFRAME]",
- "ioctl[IEEE80211_IOCTL_GETCHANINFO]",
- "ioctl[IEEE80211_IOCTL_SETOPTIE]",
- "ioctl[IEEE80211_IOCTL_GETOPTIE]",
- "ioctl[IEEE80211_IOCTL_SETMLME]",
- NULL,
- "ioctl[IEEE80211_IOCTL_SETKEY]",
- NULL,
- "ioctl[IEEE80211_IOCTL_DELKEY]",
- NULL,
- "ioctl[IEEE80211_IOCTL_ADDMAC]",
- NULL,
- "ioctl[IEEE80211_IOCTL_DELMAC]",
- NULL,
- "ioctl[IEEE80211_IOCTL_WDSMAC]",
- NULL,
- "ioctl[IEEE80211_IOCTL_WDSDELMAC]",
- NULL,
- "ioctl[IEEE80211_IOCTL_KICKMAC]",
- };
-#else /* MADWIFI_NG */
- int first = IEEE80211_IOCTL_SETPARAM;
- static const char *opnames[] = {
- "ioctl[IEEE80211_IOCTL_SETPARAM]",
- "ioctl[IEEE80211_IOCTL_GETPARAM]",
- "ioctl[IEEE80211_IOCTL_SETKEY]",
- "ioctl[SIOCIWFIRSTPRIV+3]",
- "ioctl[IEEE80211_IOCTL_DELKEY]",
- "ioctl[SIOCIWFIRSTPRIV+5]",
- "ioctl[IEEE80211_IOCTL_SETMLME]",
- "ioctl[SIOCIWFIRSTPRIV+7]",
- "ioctl[IEEE80211_IOCTL_SETOPTIE]",
- "ioctl[IEEE80211_IOCTL_GETOPTIE]",
- "ioctl[IEEE80211_IOCTL_ADDMAC]",
- "ioctl[SIOCIWFIRSTPRIV+11]",
- "ioctl[IEEE80211_IOCTL_DELMAC]",
- "ioctl[SIOCIWFIRSTPRIV+13]",
- "ioctl[IEEE80211_IOCTL_CHANLIST]",
- "ioctl[SIOCIWFIRSTPRIV+15]",
- "ioctl[IEEE80211_IOCTL_GETRSN]",
- "ioctl[SIOCIWFIRSTPRIV+17]",
- "ioctl[IEEE80211_IOCTL_GETKEY]",
- };
-#endif /* MADWIFI_NG */
- int idx = op - first;
- if (first <= op &&
- idx < (int) (sizeof(opnames) / sizeof(opnames[0])) &&
- opnames[idx])
- perror(opnames[idx]);
- else
- perror("ioctl[unknown???]");
- return -1;
- }
- return 0;
-}
-
-static int
-set80211param(struct madwifi_driver_data *drv, int op, int arg)
-{
- struct iwreq iwr;
-
- memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
- iwr.u.mode = op;
- memcpy(iwr.u.name+sizeof(__u32), &arg, sizeof(arg));
-
- if (ioctl(drv->ioctl_sock, IEEE80211_IOCTL_SETPARAM, &iwr) < 0) {
- perror("ioctl[IEEE80211_IOCTL_SETPARAM]");
- wpa_printf(MSG_DEBUG, "%s: Failed to set parameter (op %d "
- "arg %d)", __func__, op, arg);
- return -1;
- }
- return 0;
-}
-
-static const char *
-ether_sprintf(const u8 *addr)
-{
- static char buf[sizeof(MACSTR)];
-
- if (addr != NULL)
- snprintf(buf, sizeof(buf), MACSTR, MAC2STR(addr));
- else
- snprintf(buf, sizeof(buf), MACSTR, 0,0,0,0,0,0);
- return buf;
-}
-
-/*
- * Configure WPA parameters.
- */
-static int
-madwifi_configure_wpa(struct madwifi_driver_data *drv)
-{
- struct hostapd_data *hapd = drv->hapd;
- struct hostapd_bss_config *conf = hapd->conf;
- int v;
-
- switch (conf->wpa_group) {
- case WPA_CIPHER_CCMP:
- v = IEEE80211_CIPHER_AES_CCM;
- break;
- case WPA_CIPHER_TKIP:
- v = IEEE80211_CIPHER_TKIP;
- break;
- case WPA_CIPHER_WEP104:
- v = IEEE80211_CIPHER_WEP;
- break;
- case WPA_CIPHER_WEP40:
- v = IEEE80211_CIPHER_WEP;
- break;
- case WPA_CIPHER_NONE:
- v = IEEE80211_CIPHER_NONE;
- break;
- default:
- wpa_printf(MSG_ERROR, "Unknown group key cipher %u",
- conf->wpa_group);
- return -1;
- }
- wpa_printf(MSG_DEBUG, "%s: group key cipher=%d", __func__, v);
- if (set80211param(drv, IEEE80211_PARAM_MCASTCIPHER, v)) {
- printf("Unable to set group key cipher to %u\n", v);
- return -1;
- }
- if (v == IEEE80211_CIPHER_WEP) {
- /* key length is done only for specific ciphers */
- v = (conf->wpa_group == WPA_CIPHER_WEP104 ? 13 : 5);
- if (set80211param(drv, IEEE80211_PARAM_MCASTKEYLEN, v)) {
- printf("Unable to set group key length to %u\n", v);
- return -1;
- }
- }
-
- v = 0;
- if (conf->wpa_pairwise & WPA_CIPHER_CCMP)
- v |= 1<<IEEE80211_CIPHER_AES_CCM;
- if (conf->wpa_pairwise & WPA_CIPHER_TKIP)
- v |= 1<<IEEE80211_CIPHER_TKIP;
- if (conf->wpa_pairwise & WPA_CIPHER_NONE)
- v |= 1<<IEEE80211_CIPHER_NONE;
- wpa_printf(MSG_DEBUG, "%s: pairwise key ciphers=0x%x", __func__, v);
- if (set80211param(drv, IEEE80211_PARAM_UCASTCIPHERS, v)) {
- printf("Unable to set pairwise key ciphers to 0x%x\n", v);
- return -1;
- }
-
- wpa_printf(MSG_DEBUG, "%s: key management algorithms=0x%x",
- __func__, conf->wpa_key_mgmt);
- if (set80211param(drv, IEEE80211_PARAM_KEYMGTALGS, conf->wpa_key_mgmt)) {
- printf("Unable to set key management algorithms to 0x%x\n",
- conf->wpa_key_mgmt);
- return -1;
- }
-
- v = 0;
- if (conf->rsn_preauth)
- v |= BIT(0);
- wpa_printf(MSG_DEBUG, "%s: rsn capabilities=0x%x",
- __func__, conf->rsn_preauth);
- if (set80211param(drv, IEEE80211_PARAM_RSNCAPS, v)) {
- printf("Unable to set RSN capabilities to 0x%x\n", v);
- return -1;
- }
-
- wpa_printf(MSG_DEBUG, "%s: enable WPA=0x%x", __func__, conf->wpa);
- if (set80211param(drv, IEEE80211_PARAM_WPA, conf->wpa)) {
- printf("Unable to set WPA to %u\n", conf->wpa);
- return -1;
- }
- return 0;
-}
-
-
-static int
-madwifi_set_iface_flags(void *priv, int dev_up)
-{
- struct madwifi_driver_data *drv = priv;
- struct ifreq ifr;
-
- wpa_printf(MSG_DEBUG, "%s: dev_up=%d", __func__, dev_up);
-
- if (drv->ioctl_sock < 0)
- return -1;
-
- memset(&ifr, 0, sizeof(ifr));
- os_strlcpy(ifr.ifr_name, drv->iface, IFNAMSIZ);
-
- if (ioctl(drv->ioctl_sock, SIOCGIFFLAGS, &ifr) != 0) {
- perror("ioctl[SIOCGIFFLAGS]");
- return -1;
- }
-
- if (dev_up)
- ifr.ifr_flags |= IFF_UP;
- else
- ifr.ifr_flags &= ~IFF_UP;
-
- if (ioctl(drv->ioctl_sock, SIOCSIFFLAGS, &ifr) != 0) {
- perror("ioctl[SIOCSIFFLAGS]");
- return -1;
- }
-
- if (dev_up) {
- memset(&ifr, 0, sizeof(ifr));
- os_strlcpy(ifr.ifr_name, drv->iface, IFNAMSIZ);
- ifr.ifr_mtu = HOSTAPD_MTU;
- if (ioctl(drv->ioctl_sock, SIOCSIFMTU, &ifr) != 0) {
- perror("ioctl[SIOCSIFMTU]");
- printf("Setting MTU failed - trying to survive with "
- "current value\n");
- }
- }
-
- return 0;
-}
-
-static int
-madwifi_set_ieee8021x(const char *ifname, void *priv, int enabled)
-{
- struct madwifi_driver_data *drv = priv;
- struct hostapd_data *hapd = drv->hapd;
- struct hostapd_bss_config *conf = hapd->conf;
-
- wpa_printf(MSG_DEBUG, "%s: enabled=%d", __func__, enabled);
-
- if (!enabled) {
- /* XXX restore state */
- return set80211param(priv, IEEE80211_PARAM_AUTHMODE,
- IEEE80211_AUTH_AUTO);
- }
- if (!conf->wpa && !conf->ieee802_1x) {
- hostapd_logger(hapd, NULL, HOSTAPD_MODULE_DRIVER,
- HOSTAPD_LEVEL_WARNING, "No 802.1X or WPA enabled!");
- return -1;
- }
- if (conf->wpa && madwifi_configure_wpa(drv) != 0) {
- hostapd_logger(hapd, NULL, HOSTAPD_MODULE_DRIVER,
- HOSTAPD_LEVEL_WARNING, "Error configuring WPA state!");
- return -1;
- }
- if (set80211param(priv, IEEE80211_PARAM_AUTHMODE,
- (conf->wpa ? IEEE80211_AUTH_WPA : IEEE80211_AUTH_8021X))) {
- hostapd_logger(hapd, NULL, HOSTAPD_MODULE_DRIVER,
- HOSTAPD_LEVEL_WARNING, "Error enabling WPA/802.1X!");
- return -1;
- }
-
- return 0;
-}
-
-static int
-madwifi_set_privacy(const char *ifname, void *priv, int enabled)
-{
- struct madwifi_driver_data *drv = priv;
-
- wpa_printf(MSG_DEBUG, "%s: enabled=%d", __func__, enabled);
-
- return set80211param(drv, IEEE80211_PARAM_PRIVACY, enabled);
-}
-
-static int
-madwifi_set_sta_authorized(void *priv, const u8 *addr, int authorized)
-{
- struct madwifi_driver_data *drv = priv;
- struct ieee80211req_mlme mlme;
- int ret;
-
- wpa_printf(MSG_DEBUG, "%s: addr=%s authorized=%d",
- __func__, ether_sprintf(addr), authorized);
-
- if (authorized)
- mlme.im_op = IEEE80211_MLME_AUTHORIZE;
- else
- mlme.im_op = IEEE80211_MLME_UNAUTHORIZE;
- mlme.im_reason = 0;
- memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
- ret = set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
- if (ret < 0) {
- wpa_printf(MSG_DEBUG, "%s: Failed to %sauthorize STA " MACSTR,
- __func__, authorized ? "" : "un", MAC2STR(addr));
- }
-
- return ret;
-}
-
-static int
-madwifi_sta_set_flags(void *priv, const u8 *addr, int total_flags,
- int flags_or, int flags_and)
-{
- /* For now, only support setting Authorized flag */
- if (flags_or & WLAN_STA_AUTHORIZED)
- return madwifi_set_sta_authorized(priv, addr, 1);
- if (!(flags_and & WLAN_STA_AUTHORIZED))
- return madwifi_set_sta_authorized(priv, addr, 0);
- return 0;
-}
-
-static int
-madwifi_del_key(void *priv, const u8 *addr, int key_idx)
-{
- struct madwifi_driver_data *drv = priv;
- struct ieee80211req_del_key wk;
- int ret;
-
- wpa_printf(MSG_DEBUG, "%s: addr=%s key_idx=%d",
- __func__, ether_sprintf(addr), key_idx);
-
- memset(&wk, 0, sizeof(wk));
- if (addr != NULL) {
- memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
- wk.idk_keyix = (u8) IEEE80211_KEYIX_NONE;
- } else {
- wk.idk_keyix = key_idx;
- }
-
- ret = set80211priv(drv, IEEE80211_IOCTL_DELKEY, &wk, sizeof(wk));
- if (ret < 0) {
- wpa_printf(MSG_DEBUG, "%s: Failed to delete key (addr %s"
- " key_idx %d)", __func__, ether_sprintf(addr),
- key_idx);
- }
-
- return ret;
-}
-
-static int
-madwifi_set_key(const char *ifname, void *priv, const char *alg,
- const u8 *addr, int key_idx,
- const u8 *key, size_t key_len, int txkey)
-{
- struct madwifi_driver_data *drv = priv;
- struct ieee80211req_key wk;
- u_int8_t cipher;
- int ret;
-
- if (strcmp(alg, "none") == 0)
- return madwifi_del_key(drv, addr, key_idx);
-
- wpa_printf(MSG_DEBUG, "%s: alg=%s addr=%s key_idx=%d",
- __func__, alg, ether_sprintf(addr), key_idx);
-
- if (strcmp(alg, "WEP") == 0)
- cipher = IEEE80211_CIPHER_WEP;
- else if (strcmp(alg, "TKIP") == 0)
- cipher = IEEE80211_CIPHER_TKIP;
- else if (strcmp(alg, "CCMP") == 0)
- cipher = IEEE80211_CIPHER_AES_CCM;
- else {
- printf("%s: unknown/unsupported algorithm %s\n",
- __func__, alg);
- return -1;
- }
-
- if (key_len > sizeof(wk.ik_keydata)) {
- printf("%s: key length %lu too big\n", __func__,
- (unsigned long) key_len);
- return -3;
- }
-
- memset(&wk, 0, sizeof(wk));
- wk.ik_type = cipher;
- wk.ik_flags = IEEE80211_KEY_RECV | IEEE80211_KEY_XMIT;
- if (addr == NULL) {
- memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
- wk.ik_keyix = key_idx;
- wk.ik_flags |= IEEE80211_KEY_DEFAULT;
- } else {
- memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
- wk.ik_keyix = IEEE80211_KEYIX_NONE;
- }
- wk.ik_keylen = key_len;
- memcpy(wk.ik_keydata, key, key_len);
-
- ret = set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk));
- if (ret < 0) {
- wpa_printf(MSG_DEBUG, "%s: Failed to set key (addr %s"
- " key_idx %d alg '%s' key_len %lu txkey %d)",
- __func__, ether_sprintf(wk.ik_macaddr), key_idx,
- alg, (unsigned long) key_len, txkey);
- }
-
- return ret;
-}
-
-
-static int
-madwifi_get_seqnum(const char *ifname, void *priv, const u8 *addr, int idx,
- u8 *seq)
-{
- struct madwifi_driver_data *drv = priv;
- struct ieee80211req_key wk;
-
- wpa_printf(MSG_DEBUG, "%s: addr=%s idx=%d",
- __func__, ether_sprintf(addr), idx);
-
- memset(&wk, 0, sizeof(wk));
- if (addr == NULL)
- memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
- else
- memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
- wk.ik_keyix = idx;
-
- if (set80211priv(drv, IEEE80211_IOCTL_GETKEY, &wk, sizeof(wk))) {
- wpa_printf(MSG_DEBUG, "%s: Failed to get encryption data "
- "(addr " MACSTR " key_idx %d)",
- __func__, MAC2STR(wk.ik_macaddr), idx);
- return -1;
- }
-
-#ifdef WORDS_BIGENDIAN
- {
- /*
- * wk.ik_keytsc is in host byte order (big endian), need to
- * swap it to match with the byte order used in WPA.
- */
- int i;
- u8 tmp[WPA_KEY_RSC_LEN];
- memcpy(tmp, &wk.ik_keytsc, sizeof(wk.ik_keytsc));
- for (i = 0; i < WPA_KEY_RSC_LEN; i++) {
- seq[i] = tmp[WPA_KEY_RSC_LEN - i - 1];
- }
- }
-#else /* WORDS_BIGENDIAN */
- memcpy(seq, &wk.ik_keytsc, sizeof(wk.ik_keytsc));
-#endif /* WORDS_BIGENDIAN */
- return 0;
-}
-
-
-static int
-madwifi_flush(void *priv)
-{
-#ifdef MADWIFI_BSD
- u8 allsta[IEEE80211_ADDR_LEN];
- memset(allsta, 0xff, IEEE80211_ADDR_LEN);
- return madwifi_sta_deauth(priv, allsta, IEEE80211_REASON_AUTH_LEAVE);
-#else /* MADWIFI_BSD */
- return 0; /* XXX */
-#endif /* MADWIFI_BSD */
-}
-
-
-static int
-madwifi_read_sta_driver_data(void *priv, struct hostap_sta_driver_data *data,
- const u8 *addr)
-{
- struct madwifi_driver_data *drv = priv;
-
-#ifdef MADWIFI_BSD
- struct ieee80211req_sta_stats stats;
-
- memset(data, 0, sizeof(*data));
-
- /*
- * Fetch statistics for station from the system.
- */
- memset(&stats, 0, sizeof(stats));
- memcpy(stats.is_u.macaddr, addr, IEEE80211_ADDR_LEN);
- if (set80211priv(drv,
-#ifdef MADWIFI_NG
- IEEE80211_IOCTL_STA_STATS,
-#else /* MADWIFI_NG */
- IEEE80211_IOCTL_GETSTASTATS,
-#endif /* MADWIFI_NG */
- &stats, sizeof(stats))) {
- wpa_printf(MSG_DEBUG, "%s: Failed to fetch STA stats (addr "
- MACSTR ")", __func__, MAC2STR(addr));
- if (memcmp(addr, drv->acct_mac, ETH_ALEN) == 0) {
- memcpy(data, &drv->acct_data, sizeof(*data));
- return 0;
- }
-
- printf("Failed to get station stats information element.\n");
- return -1;
- }
-
- data->rx_packets = stats.is_stats.ns_rx_data;
- data->rx_bytes = stats.is_stats.ns_rx_bytes;
- data->tx_packets = stats.is_stats.ns_tx_data;
- data->tx_bytes = stats.is_stats.ns_tx_bytes;
- return 0;
-
-#else /* MADWIFI_BSD */
-
- char buf[1024], line[128], *pos;
- FILE *f;
- unsigned long val;
-
- memset(data, 0, sizeof(*data));
- snprintf(buf, sizeof(buf), "/proc/net/madwifi/%s/" MACSTR,
- drv->iface, MAC2STR(addr));
-
- f = fopen(buf, "r");
- if (!f) {
- if (memcmp(addr, drv->acct_mac, ETH_ALEN) != 0)
- return -1;
- memcpy(data, &drv->acct_data, sizeof(*data));
- return 0;
- }
- /* Need to read proc file with in one piece, so use large enough
- * buffer. */
- setbuffer(f, buf, sizeof(buf));
-
- while (fgets(line, sizeof(line), f)) {
- pos = strchr(line, '=');
- if (!pos)
- continue;
- *pos++ = '\0';
- val = strtoul(pos, NULL, 10);
- if (strcmp(line, "rx_packets") == 0)
- data->rx_packets = val;
- else if (strcmp(line, "tx_packets") == 0)
- data->tx_packets = val;
- else if (strcmp(line, "rx_bytes") == 0)
- data->rx_bytes = val;
- else if (strcmp(line, "tx_bytes") == 0)
- data->tx_bytes = val;
- }
-
- fclose(f);
-
- return 0;
-#endif /* MADWIFI_BSD */
-}
-
-
-static int
-madwifi_sta_clear_stats(void *priv, const u8 *addr)
-{
-#if defined(MADWIFI_BSD) && defined(IEEE80211_MLME_CLEAR_STATS)
- struct madwifi_driver_data *drv = priv;
- struct ieee80211req_mlme mlme;
- int ret;
-
- wpa_printf(MSG_DEBUG, "%s: addr=%s", __func__, ether_sprintf(addr));
-
- mlme.im_op = IEEE80211_MLME_CLEAR_STATS;
- memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
- ret = set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme,
- sizeof(mlme));
- if (ret < 0) {
- wpa_printf(MSG_DEBUG, "%s: Failed to clear STA stats (addr "
- MACSTR ")", __func__, MAC2STR(addr));
- }
-
- return ret;
-#else /* MADWIFI_BSD && IEEE80211_MLME_CLEAR_STATS */
- return 0; /* FIX */
-#endif /* MADWIFI_BSD && IEEE80211_MLME_CLEAR_STATS */
-}
-
-
-static int
-madwifi_set_opt_ie(const char *ifname, void *priv, const u8 *ie, size_t ie_len)
-{
- /*
- * Do nothing; we setup parameters at startup that define the
- * contents of the beacon information element.
- */
- return 0;
-}
-
-static int
-madwifi_sta_deauth(void *priv, const u8 *addr, int reason_code)
-{
- struct madwifi_driver_data *drv = priv;
- struct ieee80211req_mlme mlme;
- int ret;
-
- wpa_printf(MSG_DEBUG, "%s: addr=%s reason_code=%d",
- __func__, ether_sprintf(addr), reason_code);
-
- mlme.im_op = IEEE80211_MLME_DEAUTH;
- mlme.im_reason = reason_code;
- memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
- ret = set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
- if (ret < 0) {
- wpa_printf(MSG_DEBUG, "%s: Failed to deauth STA (addr " MACSTR
- " reason %d)",
- __func__, MAC2STR(addr), reason_code);
- }
-
- return ret;
-}
-
-static int
-madwifi_sta_disassoc(void *priv, const u8 *addr, int reason_code)
-{
- struct madwifi_driver_data *drv = priv;
- struct ieee80211req_mlme mlme;
- int ret;
-
- wpa_printf(MSG_DEBUG, "%s: addr=%s reason_code=%d",
- __func__, ether_sprintf(addr), reason_code);
-
- mlme.im_op = IEEE80211_MLME_DISASSOC;
- mlme.im_reason = reason_code;
- memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
- ret = set80211priv(drv, IEEE80211_IOCTL_SETMLME, &mlme, sizeof(mlme));
- if (ret < 0) {
- wpa_printf(MSG_DEBUG, "%s: Failed to disassoc STA (addr "
- MACSTR " reason %d)",
- __func__, MAC2STR(addr), reason_code);
- }
-
- return ret;
-}
-
-#ifdef CONFIG_WPS
-#ifdef IEEE80211_IOCTL_FILTERFRAME
-static void madwifi_raw_receive(void *ctx, const u8 *src_addr, const u8 *buf,
- size_t len)
-{
- struct madwifi_driver_data *drv = ctx;
- const struct ieee80211_mgmt *mgmt;
- const u8 *end, *ie;
- u16 fc;
- size_t ie_len;
-
- /* Send Probe Request information to WPS processing */
-
- if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req))
- return;
- mgmt = (const struct ieee80211_mgmt *) buf;
-
- fc = le_to_host16(mgmt->frame_control);
- if (WLAN_FC_GET_TYPE(fc) != WLAN_FC_TYPE_MGMT ||
- WLAN_FC_GET_STYPE(fc) != WLAN_FC_STYPE_PROBE_REQ)
- return;
-
- end = buf + len;
- ie = mgmt->u.probe_req.variable;
- ie_len = len - (IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req));
-
- hostapd_wps_probe_req_rx(drv->hapd, mgmt->sa, ie, ie_len);
-}
-#endif /* IEEE80211_IOCTL_FILTERFRAME */
-#endif /* CONFIG_WPS */
-
-static int madwifi_receive_probe_req(struct madwifi_driver_data *drv)
-{
- int ret = 0;
-#ifdef CONFIG_WPS
-#ifdef IEEE80211_IOCTL_FILTERFRAME
- struct ieee80211req_set_filter filt;
-
- wpa_printf(MSG_DEBUG, "%s Enter", __func__);
- filt.app_filterype = IEEE80211_FILTER_TYPE_PROBE_REQ;
-
- ret = set80211priv(drv, IEEE80211_IOCTL_FILTERFRAME, &filt,
- sizeof(struct ieee80211req_set_filter));
- if (ret)
- return ret;
-
- drv->sock_raw = l2_packet_init(drv->iface, NULL, ETH_P_80211_RAW,
- madwifi_raw_receive, drv, 1);
- if (drv->sock_raw == NULL)
- return -1;
-#endif /* IEEE80211_IOCTL_FILTERFRAME */
-#endif /* CONFIG_WPS */
- return ret;
-}
-
-static int
-madwifi_del_sta(struct madwifi_driver_data *drv, u8 addr[IEEE80211_ADDR_LEN])
-{
- struct hostapd_data *hapd = drv->hapd;
- struct sta_info *sta;
-
- hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
- HOSTAPD_LEVEL_INFO, "disassociated");
-
- sta = ap_get_sta(hapd, addr);
- if (sta != NULL) {
- sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
- wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC);
- sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
- ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
- ap_free_sta(hapd, sta);
- }
- return 0;
-}
-
-#ifdef CONFIG_WPS
-static int
-madwifi_set_wps_ie(void *priv, const u8 *ie, size_t len, u32 frametype)
-{
- struct madwifi_driver_data *drv = priv;
- u8 buf[256];
- struct ieee80211req_getset_appiebuf *beac_ie;
-
- wpa_printf(MSG_DEBUG, "%s buflen = %lu", __func__,
- (unsigned long) len);
-
- beac_ie = (struct ieee80211req_getset_appiebuf *) buf;
- beac_ie->app_frmtype = frametype;
- beac_ie->app_buflen = len;
- memcpy(&(beac_ie->app_buf[0]), ie, len);
-
- return set80211priv(drv, IEEE80211_IOCTL_SET_APPIEBUF, beac_ie,
- sizeof(struct ieee80211req_getset_appiebuf) + len);
-}
-
-static int
-madwifi_set_wps_beacon_ie(const char *ifname, void *priv, const u8 *ie,
- size_t len)
-{
- return madwifi_set_wps_ie(priv, ie, len, IEEE80211_APPIE_FRAME_BEACON);
-}
-
-static int
-madwifi_set_wps_probe_resp_ie(const char *ifname, void *priv, const u8 *ie,
- size_t len)
-{
- return madwifi_set_wps_ie(priv, ie, len,
- IEEE80211_APPIE_FRAME_PROBE_RESP);
-}
-#else /* CONFIG_WPS */
-#define madwifi_set_wps_beacon_ie NULL
-#define madwifi_set_wps_probe_resp_ie NULL
-#endif /* CONFIG_WPS */
-
-static int
-madwifi_process_wpa_ie(struct madwifi_driver_data *drv, struct sta_info *sta)
-{
- struct hostapd_data *hapd = drv->hapd;
- struct ieee80211req_wpaie ie;
- int ielen, res;
- u8 *iebuf;
-
- /*
- * Fetch negotiated WPA/RSN parameters from the system.
- */
- memset(&ie, 0, sizeof(ie));
- memcpy(ie.wpa_macaddr, sta->addr, IEEE80211_ADDR_LEN);
- if (set80211priv(drv, IEEE80211_IOCTL_GETWPAIE, &ie, sizeof(ie))) {
- wpa_printf(MSG_ERROR, "%s: Failed to get WPA/RSN IE",
- __func__);
- printf("Failed to get WPA/RSN information element.\n");
- return -1; /* XXX not right */
- }
- wpa_hexdump(MSG_MSGDUMP, "madwifi req WPA IE",
- ie.wpa_ie, IEEE80211_MAX_OPT_IE);
- iebuf = ie.wpa_ie;
- /* madwifi seems to return some random data if WPA/RSN IE is not set.
- * Assume the IE was not included if the IE type is unknown. */
- if (iebuf[0] != WLAN_EID_VENDOR_SPECIFIC)
- iebuf[1] = 0;
-#ifdef MADWIFI_NG
- wpa_hexdump(MSG_MSGDUMP, "madwifi req RSN IE",
- ie.rsn_ie, IEEE80211_MAX_OPT_IE);
- if (iebuf[1] == 0 && ie.rsn_ie[1] > 0) {
- /* madwifi-ng svn #1453 added rsn_ie. Use it, if wpa_ie was not
- * set. This is needed for WPA2. */
- iebuf = ie.rsn_ie;
- if (iebuf[0] != WLAN_EID_RSN)
- iebuf[1] = 0;
- }
-#endif /* MADWIFI_NG */
- ielen = iebuf[1];
- if (ielen == 0) {
-#ifdef CONFIG_WPS
- if (hapd->conf->wps_state) {
- wpa_printf(MSG_DEBUG, "STA did not include WPA/RSN IE "
- "in (Re)Association Request - possible WPS "
- "use");
- sta->flags |= WLAN_STA_MAYBE_WPS;
- return 0;
- }
-#endif /* CONFIG_WPS */
- printf("No WPA/RSN information element for station!?\n");
- return -1; /* XXX not right */
- }
- ielen += 2;
- if (sta->wpa_sm == NULL)
- sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth, sta->addr);
- if (sta->wpa_sm == NULL) {
- printf("Failed to initialize WPA state machine\n");
- return -1;
- }
- res = wpa_validate_wpa_ie(hapd->wpa_auth, sta->wpa_sm,
- iebuf, ielen, NULL, 0);
- if (res != WPA_IE_OK) {
- printf("WPA/RSN information element rejected? (res %u)\n", res);
- return -1;
- }
- return 0;
-}
-
-static int
-madwifi_new_sta(struct madwifi_driver_data *drv, u8 addr[IEEE80211_ADDR_LEN])
-{
- struct hostapd_data *hapd = drv->hapd;
- struct sta_info *sta;
- int new_assoc;
-
- hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
- HOSTAPD_LEVEL_INFO, "associated");
-
- sta = ap_get_sta(hapd, addr);
- if (sta) {
- accounting_sta_stop(hapd, sta);
- } else {
- sta = ap_sta_add(hapd, addr);
- if (sta == NULL)
- return -1;
- }
-
- if (memcmp(addr, drv->acct_mac, ETH_ALEN) == 0) {
- /* Cached accounting data is not valid anymore. */
- memset(drv->acct_mac, 0, ETH_ALEN);
- memset(&drv->acct_data, 0, sizeof(drv->acct_data));
- }
-
- if (hapd->conf->wpa) {
- if (madwifi_process_wpa_ie(drv, sta))
- return -1;
- }
-
- /*
- * Now that the internal station state is setup
- * kick the authenticator into action.
- */
- new_assoc = (sta->flags & WLAN_STA_ASSOC) == 0;
- sta->flags |= WLAN_STA_AUTH | WLAN_STA_ASSOC;
- wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC);
- hostapd_new_assoc_sta(hapd, sta, !new_assoc);
- ieee802_1x_notify_port_enabled(sta->eapol_sm, 1);
- return 0;
-}
-
-static void
-madwifi_wireless_event_wireless_custom(struct madwifi_driver_data *drv,
- char *custom)
-{
- wpa_printf(MSG_DEBUG, "Custom wireless event: '%s'", custom);
-
- if (strncmp(custom, "MLME-MICHAELMICFAILURE.indication", 33) == 0) {
- char *pos;
- u8 addr[ETH_ALEN];
- pos = strstr(custom, "addr=");
- if (pos == NULL) {
- wpa_printf(MSG_DEBUG,
- "MLME-MICHAELMICFAILURE.indication "
- "without sender address ignored");
- return;
- }
- pos += 5;
- if (hwaddr_aton(pos, addr) == 0) {
- ieee80211_michael_mic_failure(drv->hapd, addr, 1);
- } else {
- wpa_printf(MSG_DEBUG,
- "MLME-MICHAELMICFAILURE.indication "
- "with invalid MAC address");
- }
- } else if (strncmp(custom, "STA-TRAFFIC-STAT", 16) == 0) {
- char *key, *value;
- u32 val;
- key = custom;
- while ((key = strchr(key, '\n')) != NULL) {
- key++;
- value = strchr(key, '=');
- if (value == NULL)
- continue;
- *value++ = '\0';
- val = strtoul(value, NULL, 10);
- if (strcmp(key, "mac") == 0)
- hwaddr_aton(value, drv->acct_mac);
- else if (strcmp(key, "rx_packets") == 0)
- drv->acct_data.rx_packets = val;
- else if (strcmp(key, "tx_packets") == 0)
- drv->acct_data.tx_packets = val;
- else if (strcmp(key, "rx_bytes") == 0)
- drv->acct_data.rx_bytes = val;
- else if (strcmp(key, "tx_bytes") == 0)
- drv->acct_data.tx_bytes = val;
- key = value;
- }
- }
-}
-
-static void
-madwifi_wireless_event_wireless(struct madwifi_driver_data *drv,
- char *data, int len)
-{
- struct iw_event iwe_buf, *iwe = &iwe_buf;
- char *pos, *end, *custom, *buf;
-
- pos = data;
- end = data + len;
-
- while (pos + IW_EV_LCP_LEN <= end) {
- /* Event data may be unaligned, so make a local, aligned copy
- * before processing. */
- memcpy(&iwe_buf, pos, IW_EV_LCP_LEN);
- wpa_printf(MSG_MSGDUMP, "Wireless event: cmd=0x%x len=%d",
- iwe->cmd, iwe->len);
- if (iwe->len <= IW_EV_LCP_LEN)
- return;
-
- custom = pos + IW_EV_POINT_LEN;
- if (drv->we_version > 18 &&
- (iwe->cmd == IWEVMICHAELMICFAILURE ||
- iwe->cmd == IWEVCUSTOM)) {
- /* WE-19 removed the pointer from struct iw_point */
- char *dpos = (char *) &iwe_buf.u.data.length;
- int dlen = dpos - (char *) &iwe_buf;
- memcpy(dpos, pos + IW_EV_LCP_LEN,
- sizeof(struct iw_event) - dlen);
- } else {
- memcpy(&iwe_buf, pos, sizeof(struct iw_event));
- custom += IW_EV_POINT_OFF;
- }
-
- switch (iwe->cmd) {
- case IWEVEXPIRED:
- madwifi_del_sta(drv, (u8 *) iwe->u.addr.sa_data);
- break;
- case IWEVREGISTERED:
- madwifi_new_sta(drv, (u8 *) iwe->u.addr.sa_data);
- break;
- case IWEVCUSTOM:
- if (custom + iwe->u.data.length > end)
- return;
- buf = malloc(iwe->u.data.length + 1);
- if (buf == NULL)
- return; /* XXX */
- memcpy(buf, custom, iwe->u.data.length);
- buf[iwe->u.data.length] = '\0';
- madwifi_wireless_event_wireless_custom(drv, buf);
- free(buf);
- break;
- }
-
- pos += iwe->len;
- }
-}
-
-
-static void
-madwifi_wireless_event_rtm_newlink(struct madwifi_driver_data *drv,
- struct nlmsghdr *h, int len)
-{
- struct ifinfomsg *ifi;
- int attrlen, nlmsg_len, rta_len;
- struct rtattr * attr;
-
- if (len < (int) sizeof(*ifi))
- return;
-
- ifi = NLMSG_DATA(h);
-
- if (ifi->ifi_index != drv->ifindex)
- return;
-
- nlmsg_len = NLMSG_ALIGN(sizeof(struct ifinfomsg));
-
- attrlen = h->nlmsg_len - nlmsg_len;
- if (attrlen < 0)
- return;
-
- attr = (struct rtattr *) (((char *) ifi) + nlmsg_len);
-
- rta_len = RTA_ALIGN(sizeof(struct rtattr));
- while (RTA_OK(attr, attrlen)) {
- if (attr->rta_type == IFLA_WIRELESS) {
- madwifi_wireless_event_wireless(
- drv, ((char *) attr) + rta_len,
- attr->rta_len - rta_len);
- }
- attr = RTA_NEXT(attr, attrlen);
- }
-}
-
-
-static void
-madwifi_wireless_event_receive(int sock, void *eloop_ctx, void *sock_ctx)
-{
- char buf[256];
- int left;
- struct sockaddr_nl from;
- socklen_t fromlen;
- struct nlmsghdr *h;
- struct madwifi_driver_data *drv = eloop_ctx;
-
- fromlen = sizeof(from);
- left = recvfrom(sock, buf, sizeof(buf), MSG_DONTWAIT,
- (struct sockaddr *) &from, &fromlen);
- if (left < 0) {
- if (errno != EINTR && errno != EAGAIN)
- perror("recvfrom(netlink)");
- return;
- }
-
- h = (struct nlmsghdr *) buf;
- while (left >= (int) sizeof(*h)) {
- int len, plen;
-
- len = h->nlmsg_len;
- plen = len - sizeof(*h);
- if (len > left || plen < 0) {
- printf("Malformed netlink message: "
- "len=%d left=%d plen=%d\n",
- len, left, plen);
- break;
- }
-
- switch (h->nlmsg_type) {
- case RTM_NEWLINK:
- madwifi_wireless_event_rtm_newlink(drv, h, plen);
- break;
- }
-
- len = NLMSG_ALIGN(len);
- left -= len;
- h = (struct nlmsghdr *) ((char *) h + len);
- }
-
- if (left > 0) {
- printf("%d extra bytes in the end of netlink message\n", left);
- }
-}
-
-
-static int
-madwifi_get_we_version(struct madwifi_driver_data *drv)
-{
- struct iw_range *range;
- struct iwreq iwr;
- int minlen;
- size_t buflen;
-
- drv->we_version = 0;
-
- /*
- * Use larger buffer than struct iw_range in order to allow the
- * structure to grow in the future.
- */
- buflen = sizeof(struct iw_range) + 500;
- range = os_zalloc(buflen);
- if (range == NULL)
- return -1;
-
- memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
- iwr.u.data.pointer = (caddr_t) range;
- iwr.u.data.length = buflen;
-
- minlen = ((char *) &range->enc_capa) - (char *) range +
- sizeof(range->enc_capa);
-
- if (ioctl(drv->ioctl_sock, SIOCGIWRANGE, &iwr) < 0) {
- perror("ioctl[SIOCGIWRANGE]");
- free(range);
- return -1;
- } else if (iwr.u.data.length >= minlen &&
- range->we_version_compiled >= 18) {
- wpa_printf(MSG_DEBUG, "SIOCGIWRANGE: WE(compiled)=%d "
- "WE(source)=%d enc_capa=0x%x",
- range->we_version_compiled,
- range->we_version_source,
- range->enc_capa);
- drv->we_version = range->we_version_compiled;
- }
-
- free(range);
- return 0;
-}
-
-
-static int
-madwifi_wireless_event_init(void *priv)
-{
- struct madwifi_driver_data *drv = priv;
- int s;
- struct sockaddr_nl local;
-
- madwifi_get_we_version(drv);
-
- drv->wext_sock = -1;
-
- s = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
- if (s < 0) {
- perror("socket(PF_NETLINK,SOCK_RAW,NETLINK_ROUTE)");
- return -1;
- }
-
- memset(&local, 0, sizeof(local));
- local.nl_family = AF_NETLINK;
- local.nl_groups = RTMGRP_LINK;
- if (bind(s, (struct sockaddr *) &local, sizeof(local)) < 0) {
- perror("bind(netlink)");
- close(s);
- return -1;
- }
-
- eloop_register_read_sock(s, madwifi_wireless_event_receive, drv, NULL);
- drv->wext_sock = s;
-
- return 0;
-}
-
-
-static void
-madwifi_wireless_event_deinit(void *priv)
-{
- struct madwifi_driver_data *drv = priv;
-
- if (drv != NULL) {
- if (drv->wext_sock < 0)
- return;
- eloop_unregister_read_sock(drv->wext_sock);
- close(drv->wext_sock);
- }
-}
-
-
-static int
-madwifi_send_eapol(void *priv, const u8 *addr, const u8 *data, size_t data_len,
- int encrypt, const u8 *own_addr)
-{
- struct madwifi_driver_data *drv = priv;
- unsigned char buf[3000];
- unsigned char *bp = buf;
- struct l2_ethhdr *eth;
- size_t len;
- int status;
-
- /*
- * Prepend the Ethernet header. If the caller left us
- * space at the front we could just insert it but since
- * we don't know we copy to a local buffer. Given the frequency
- * and size of frames this probably doesn't matter.
- */
- len = data_len + sizeof(struct l2_ethhdr);
- if (len > sizeof(buf)) {
- bp = malloc(len);
- if (bp == NULL) {
- printf("EAPOL frame discarded, cannot malloc temp "
- "buffer of size %lu!\n", (unsigned long) len);
- return -1;
- }
- }
- eth = (struct l2_ethhdr *) bp;
- memcpy(eth->h_dest, addr, ETH_ALEN);
- memcpy(eth->h_source, own_addr, ETH_ALEN);
- eth->h_proto = htons(ETH_P_EAPOL);
- memcpy(eth+1, data, data_len);
-
- wpa_hexdump(MSG_MSGDUMP, "TX EAPOL", bp, len);
-
- status = l2_packet_send(drv->sock_xmit, addr, ETH_P_EAPOL, bp, len);
-
- if (bp != buf)
- free(bp);
- return status;
-}
-
-static void
-handle_read(void *ctx, const u8 *src_addr, const u8 *buf, size_t len)
-{
- struct madwifi_driver_data *drv = ctx;
- struct hostapd_data *hapd = drv->hapd;
- struct sta_info *sta;
-
- sta = ap_get_sta(hapd, src_addr);
- if (!sta || !(sta->flags & WLAN_STA_ASSOC)) {
- printf("Data frame from not associated STA %s\n",
- ether_sprintf(src_addr));
- /* XXX cannot happen */
- return;
- }
- ieee802_1x_receive(hapd, src_addr, buf + sizeof(struct l2_ethhdr),
- len - sizeof(struct l2_ethhdr));
-}
-
-static void *
-madwifi_init(struct hostapd_data *hapd)
-{
- struct madwifi_driver_data *drv;
- struct ifreq ifr;
- struct iwreq iwr;
-
- drv = os_zalloc(sizeof(struct madwifi_driver_data));
- if (drv == NULL) {
- printf("Could not allocate memory for madwifi driver data\n");
- return NULL;
- }
-
- drv->hapd = hapd;
- drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
- if (drv->ioctl_sock < 0) {
- perror("socket[PF_INET,SOCK_DGRAM]");
- goto bad;
- }
- memcpy(drv->iface, hapd->conf->iface, sizeof(drv->iface));
-
- memset(&ifr, 0, sizeof(ifr));
- os_strlcpy(ifr.ifr_name, drv->iface, sizeof(ifr.ifr_name));
- if (ioctl(drv->ioctl_sock, SIOCGIFINDEX, &ifr) != 0) {
- perror("ioctl(SIOCGIFINDEX)");
- goto bad;
- }
- drv->ifindex = ifr.ifr_ifindex;
-
- drv->sock_xmit = l2_packet_init(drv->iface, NULL, ETH_P_EAPOL,
- handle_read, drv, 1);
- if (drv->sock_xmit == NULL)
- goto bad;
- if (l2_packet_get_own_addr(drv->sock_xmit, hapd->own_addr))
- goto bad;
- if (hapd->conf->bridge[0] != '\0') {
- wpa_printf(MSG_DEBUG, "Configure bridge %s for EAPOL traffic.",
- hapd->conf->bridge);
- drv->sock_recv = l2_packet_init(hapd->conf->bridge, NULL,
- ETH_P_EAPOL, handle_read, drv,
- 1);
- if (drv->sock_recv == NULL)
- goto bad;
- } else
- drv->sock_recv = drv->sock_xmit;
-
- memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
-
- iwr.u.mode = IW_MODE_MASTER;
-
- if (ioctl(drv->ioctl_sock, SIOCSIWMODE, &iwr) < 0) {
- perror("ioctl[SIOCSIWMODE]");
- printf("Could not set interface to master mode!\n");
- goto bad;
- }
-
- madwifi_set_iface_flags(drv, 0); /* mark down during setup */
- madwifi_set_privacy(drv->iface, drv, 0); /* default to no privacy */
-
- madwifi_receive_probe_req(drv);
-
- return drv;
-bad:
- if (drv->sock_xmit != NULL)
- l2_packet_deinit(drv->sock_xmit);
- if (drv->ioctl_sock >= 0)
- close(drv->ioctl_sock);
- if (drv != NULL)
- free(drv);
- return NULL;
-}
-
-
-static void
-madwifi_deinit(void *priv)
-{
- struct madwifi_driver_data *drv = priv;
-
- (void) madwifi_set_iface_flags(drv, 0);
- if (drv->ioctl_sock >= 0)
- close(drv->ioctl_sock);
- if (drv->sock_recv != NULL && drv->sock_recv != drv->sock_xmit)
- l2_packet_deinit(drv->sock_recv);
- if (drv->sock_xmit != NULL)
- l2_packet_deinit(drv->sock_xmit);
- if (drv->sock_raw)
- l2_packet_deinit(drv->sock_raw);
- free(drv);
-}
-
-static int
-madwifi_set_ssid(const char *ifname, void *priv, const u8 *buf, int len)
-{
- struct madwifi_driver_data *drv = priv;
- struct iwreq iwr;
-
- memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
- iwr.u.essid.flags = 1; /* SSID active */
- iwr.u.essid.pointer = (caddr_t) buf;
- iwr.u.essid.length = len + 1;
-
- if (ioctl(drv->ioctl_sock, SIOCSIWESSID, &iwr) < 0) {
- perror("ioctl[SIOCSIWESSID]");
- printf("len=%d\n", len);
- return -1;
- }
- return 0;
-}
-
-static int
-madwifi_get_ssid(const char *ifname, void *priv, u8 *buf, int len)
-{
- struct madwifi_driver_data *drv = priv;
- struct iwreq iwr;
- int ret = 0;
-
- memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
- iwr.u.essid.pointer = (caddr_t) buf;
- iwr.u.essid.length = len;
-
- if (ioctl(drv->ioctl_sock, SIOCGIWESSID, &iwr) < 0) {
- perror("ioctl[SIOCGIWESSID]");
- ret = -1;
- } else
- ret = iwr.u.essid.length;
-
- return ret;
-}
-
-static int
-madwifi_set_countermeasures(void *priv, int enabled)
-{
- struct madwifi_driver_data *drv = priv;
- wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled);
- return set80211param(drv, IEEE80211_PARAM_COUNTERMEASURES, enabled);
-}
-
-static int
-madwifi_commit(void *priv)
-{
- return madwifi_set_iface_flags(priv, 1);
-}
-
-const struct wpa_driver_ops wpa_driver_madwifi_ops = {
- .name = "madwifi",
- .init = madwifi_init,
- .deinit = madwifi_deinit,
- .set_ieee8021x = madwifi_set_ieee8021x,
- .set_privacy = madwifi_set_privacy,
- .set_encryption = madwifi_set_key,
- .get_seqnum = madwifi_get_seqnum,
- .flush = madwifi_flush,
- .set_generic_elem = madwifi_set_opt_ie,
- .wireless_event_init = madwifi_wireless_event_init,
- .wireless_event_deinit = madwifi_wireless_event_deinit,
- .sta_set_flags = madwifi_sta_set_flags,
- .read_sta_data = madwifi_read_sta_driver_data,
- .send_eapol = madwifi_send_eapol,
- .sta_disassoc = madwifi_sta_disassoc,
- .sta_deauth = madwifi_sta_deauth,
- .set_ssid = madwifi_set_ssid,
- .get_ssid = madwifi_get_ssid,
- .set_countermeasures = madwifi_set_countermeasures,
- .sta_clear_stats = madwifi_sta_clear_stats,
- .commit = madwifi_commit,
- .set_wps_beacon_ie = madwifi_set_wps_beacon_ie,
- .set_wps_probe_resp_ie = madwifi_set_wps_probe_resp_ie,
-};
diff --git a/hostapd/driver_nl80211.c b/hostapd/driver_nl80211.c
deleted file mode 100644
index 4599e99eadcd..000000000000
--- a/hostapd/driver_nl80211.c
+++ /dev/null
@@ -1,2708 +0,0 @@
-/*
- * hostapd / Kernel driver communication via nl80211
- * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
- * Copyright (c) 2003-2004, Instant802 Networks, Inc.
- * Copyright (c) 2005-2006, Devicescape Software, Inc.
- * Copyright (c) 2007, Johannes Berg <johannes@sipsolutions.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Alternatively, this software may be distributed under the terms of BSD
- * license.
- *
- * See README and COPYING for more details.
- */
-
-#include "includes.h"
-
-#include <sys/ioctl.h>
-#include <netlink/genl/genl.h>
-#include <netlink/genl/family.h>
-#include <netlink/genl/ctrl.h>
-#include <netlink/msg.h>
-#include <netlink/attr.h>
-#include "nl80211_copy.h"
-#include <net/if.h>
-#include <netpacket/packet.h>
-#include "wireless_copy.h"
-#include <linux/filter.h>
-#include <net/if_arp.h>
-
-#include "hostapd.h"
-#include "driver.h"
-#include "ieee802_1x.h"
-#include "eloop.h"
-#include "ieee802_11.h"
-#include "sta_info.h"
-#include "hw_features.h"
-#include "mlme.h"
-#include "radiotap.h"
-#include "radiotap_iter.h"
-
-#ifdef CONFIG_LIBNL20
-/* libnl 2.0 compatibility code */
-#define nl_handle_alloc_cb nl_socket_alloc_cb
-#define nl_handle_destroy nl_socket_free
-#endif /* CONFIG_LIBNL20 */
-
-enum ieee80211_msg_type {
- ieee80211_msg_normal = 0,
- ieee80211_msg_tx_callback_ack = 1,
- ieee80211_msg_tx_callback_fail = 2,
-};
-
-struct i802_driver_data {
- struct hostapd_data *hapd;
-
- char iface[IFNAMSIZ + 1];
- int bridge;
- int ioctl_sock; /* socket for ioctl() use */
- int wext_sock; /* socket for wireless events */
- int eapol_sock; /* socket for EAPOL frames */
- int monitor_sock; /* socket for monitor */
- int monitor_ifidx;
-
- int default_if_indices[16];
- int *if_indices;
- int num_if_indices;
-
- int we_version;
- struct nl_handle *nl_handle;
- struct nl_cache *nl_cache;
- struct nl_cb *nl_cb;
- struct genl_family *nl80211;
- int dtim_period, beacon_int;
- unsigned int beacon_set:1;
- unsigned int ieee802_1x_active:1;
-
- int last_freq;
- int last_freq_ht;
-};
-
-
-static void add_ifidx(struct i802_driver_data *drv, int ifidx)
-{
- int i;
- int *old;
-
- for (i = 0; i < drv->num_if_indices; i++) {
- if (drv->if_indices[i] == 0) {
- drv->if_indices[i] = ifidx;
- return;
- }
- }
-
- if (drv->if_indices != drv->default_if_indices)
- old = drv->if_indices;
- else
- old = NULL;
-
- drv->if_indices = realloc(old,
- sizeof(int) * (drv->num_if_indices + 1));
- if (!drv->if_indices) {
- if (!old)
- drv->if_indices = drv->default_if_indices;
- else
- drv->if_indices = old;
- wpa_printf(MSG_ERROR, "Failed to reallocate memory for "
- "interfaces");
- wpa_printf(MSG_ERROR, "Ignoring EAPOL on interface %d", ifidx);
- return;
- }
- drv->if_indices[drv->num_if_indices] = ifidx;
- drv->num_if_indices++;
-}
-
-
-static void del_ifidx(struct i802_driver_data *drv, int ifidx)
-{
- int i;
-
- for (i = 0; i < drv->num_if_indices; i++) {
- if (drv->if_indices[i] == ifidx) {
- drv->if_indices[i] = 0;
- break;
- }
- }
-}
-
-
-static int have_ifidx(struct i802_driver_data *drv, int ifidx)
-{
- int i;
-
- if (ifidx == drv->bridge)
- return 1;
-
- for (i = 0; i < drv->num_if_indices; i++)
- if (drv->if_indices[i] == ifidx)
- return 1;
-
- return 0;
-}
-
-
-/* nl80211 code */
-static int ack_handler(struct nl_msg *msg, void *arg)
-{
- int *err = arg;
- *err = 0;
- return NL_STOP;
-}
-
-static int finish_handler(struct nl_msg *msg, void *arg)
-{
- int *ret = arg;
- *ret = 0;
- return NL_SKIP;
-}
-
-static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err,
- void *arg)
-{
- int *ret = arg;
- *ret = err->error;
- return NL_SKIP;
-}
-
-static int send_and_recv_msgs(struct i802_driver_data *drv,
- struct nl_msg *msg,
- int (*valid_handler)(struct nl_msg *, void *),
- void *valid_data)
-{
- struct nl_cb *cb;
- int err = -ENOMEM;
-
- cb = nl_cb_clone(drv->nl_cb);
- if (!cb)
- goto out;
-
- err = nl_send_auto_complete(drv->nl_handle, msg);
- if (err < 0)
- goto out;
-
- err = 1;
-
- nl_cb_err(cb, NL_CB_CUSTOM, error_handler, &err);
- nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, &err);
- nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &err);
-
- if (valid_handler)
- nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM,
- valid_handler, valid_data);
-
- while (err > 0)
- nl_recvmsgs(drv->nl_handle, cb);
- out:
- nl_cb_put(cb);
- nlmsg_free(msg);
- return err;
-}
-
-static int hostapd_set_iface_flags(struct i802_driver_data *drv,
- const char *ifname, int dev_up)
-{
- struct ifreq ifr;
-
- if (drv->ioctl_sock < 0)
- return -1;
-
- memset(&ifr, 0, sizeof(ifr));
- os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
-
- if (ioctl(drv->ioctl_sock, SIOCGIFFLAGS, &ifr) != 0) {
- perror("ioctl[SIOCGIFFLAGS]");
- wpa_printf(MSG_DEBUG, "Could not read interface flags (%s)",
- drv->iface);
- return -1;
- }
-
- if (dev_up)
- ifr.ifr_flags |= IFF_UP;
- else
- ifr.ifr_flags &= ~IFF_UP;
-
- if (ioctl(drv->ioctl_sock, SIOCSIFFLAGS, &ifr) != 0) {
- perror("ioctl[SIOCSIFFLAGS]");
- return -1;
- }
-
- return 0;
-}
-
-
-static int nl_set_encr(int ifindex, struct i802_driver_data *drv,
- const char *alg, const u8 *addr, int idx, const u8 *key,
- size_t key_len, int txkey)
-{
- struct nl_msg *msg;
- int ret;
-
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- if (strcmp(alg, "none") == 0) {
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_DEL_KEY, 0);
- } else {
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_NEW_KEY, 0);
- NLA_PUT(msg, NL80211_ATTR_KEY_DATA, key_len, key);
- if (strcmp(alg, "WEP") == 0) {
- if (key_len == 5)
- NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER,
- 0x000FAC01);
- else
- NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER,
- 0x000FAC05);
- } else if (strcmp(alg, "TKIP") == 0)
- NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER, 0x000FAC02);
- else if (strcmp(alg, "CCMP") == 0)
- NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER, 0x000FAC04);
- else if (strcmp(alg, "IGTK") == 0)
- NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER, 0x000FAC06);
- else {
- wpa_printf(MSG_ERROR, "%s: Unsupported encryption "
- "algorithm '%s'", __func__, alg);
- nlmsg_free(msg);
- return -1;
- }
- }
-
- if (addr)
- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
- NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, idx);
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex);
-
- ret = send_and_recv_msgs(drv, msg, NULL, NULL);
- if (ret == -ENOENT)
- ret = 0;
-
- /*
- * If we failed or don't need to set the default TX key (below),
- * we're done here.
- */
- if (ret || !txkey || addr)
- return ret;
-
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_SET_KEY, 0);
- NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, idx);
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex);
- if (strcmp(alg, "IGTK") == 0)
- NLA_PUT_FLAG(msg, NL80211_ATTR_KEY_DEFAULT_MGMT);
- else
- NLA_PUT_FLAG(msg, NL80211_ATTR_KEY_DEFAULT);
-
- ret = send_and_recv_msgs(drv, msg, NULL, NULL);
- if (ret == -ENOENT)
- ret = 0;
- return ret;
- nla_put_failure:
- return -ENOBUFS;
-}
-
-
-static int i802_set_encryption(const char *iface, void *priv, const char *alg,
- const u8 *addr, int idx, const u8 *key,
- size_t key_len, int txkey)
-{
- struct i802_driver_data *drv = priv;
- int ret;
-
- ret = nl_set_encr(if_nametoindex(iface), drv, alg, addr, idx, key,
- key_len, txkey);
- if (ret < 0)
- return ret;
-
- return ret;
-}
-
-
-static inline int min_int(int a, int b)
-{
- if (a < b)
- return a;
- return b;
-}
-
-
-static int get_key_handler(struct nl_msg *msg, void *arg)
-{
- struct nlattr *tb[NL80211_ATTR_MAX + 1];
- struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
-
- nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
- genlmsg_attrlen(gnlh, 0), NULL);
-
- /*
- * TODO: validate the key index and mac address!
- * Otherwise, there's a race condition as soon as
- * the kernel starts sending key notifications.
- */
-
- if (tb[NL80211_ATTR_KEY_SEQ])
- memcpy(arg, nla_data(tb[NL80211_ATTR_KEY_SEQ]),
- min_int(nla_len(tb[NL80211_ATTR_KEY_SEQ]), 6));
- return NL_SKIP;
-}
-
-
-static int i802_get_seqnum(const char *iface, void *priv, const u8 *addr,
- int idx, u8 *seq)
-{
- struct i802_driver_data *drv = priv;
- struct nl_msg *msg;
-
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_GET_KEY, 0);
-
- if (addr)
- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
- NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, idx);
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
-
- memset(seq, 0, 6);
-
- return send_and_recv_msgs(drv, msg, get_key_handler, seq);
- nla_put_failure:
- return -ENOBUFS;
-}
-
-
-static int i802_set_rate_sets(void *priv, int *supp_rates, int *basic_rates,
- int mode)
-{
- struct i802_driver_data *drv = priv;
- struct nl_msg *msg;
- u8 rates[NL80211_MAX_SUPP_RATES];
- u8 rates_len = 0;
- int i;
-
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
- NL80211_CMD_SET_BSS, 0);
-
- for (i = 0; i < NL80211_MAX_SUPP_RATES && basic_rates[i] >= 0; i++)
- rates[rates_len++] = basic_rates[i] / 5;
-
- NLA_PUT(msg, NL80211_ATTR_BSS_BASIC_RATES, rates_len, rates);
-
- /* TODO: multi-BSS support */
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
-
- return send_and_recv_msgs(drv, msg, NULL, NULL);
- nla_put_failure:
- return -ENOBUFS;
-}
-
-
-static int i802_send_frame(void *priv, const void *data, size_t len,
- int encrypt, int flags)
-{
- __u8 rtap_hdr[] = {
- 0x00, 0x00, /* radiotap version */
- 0x0e, 0x00, /* radiotap length */
- 0x02, 0xc0, 0x00, 0x00, /* bmap: flags, tx and rx flags */
- IEEE80211_RADIOTAP_F_FRAG, /* F_FRAG (fragment if required) */
- 0x00, /* padding */
- 0x00, 0x00, /* RX and TX flags to indicate that */
- 0x00, 0x00, /* this is the injected frame directly */
- };
- struct i802_driver_data *drv = priv;
- struct iovec iov[2] = {
- {
- .iov_base = &rtap_hdr,
- .iov_len = sizeof(rtap_hdr),
- },
- {
- .iov_base = (void*)data,
- .iov_len = len,
- }
- };
- struct msghdr msg = {
- .msg_name = NULL,
- .msg_namelen = 0,
- .msg_iov = iov,
- .msg_iovlen = 2,
- .msg_control = NULL,
- .msg_controllen = 0,
- .msg_flags = 0,
- };
-
- if (encrypt)
- rtap_hdr[8] |= IEEE80211_RADIOTAP_F_WEP;
-
- return sendmsg(drv->monitor_sock, &msg, flags);
-}
-
-static int i802_send_mgmt_frame(void *priv, const void *data, size_t len,
- int flags)
-{
- struct ieee80211_mgmt *mgmt;
- int do_not_encrypt = 0;
- u16 fc;
-
- mgmt = (struct ieee80211_mgmt *) data;
- fc = le_to_host16(mgmt->frame_control);
-
- if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT &&
- WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_AUTH) {
- /*
- * Only one of the authentication frame types is encrypted.
- * In order for static WEP encryption to work properly (i.e.,
- * to not encrypt the frame), we need to tell mac80211 about
- * the frames that must not be encrypted.
- */
- u16 auth_alg = le_to_host16(mgmt->u.auth.auth_alg);
- u16 auth_trans = le_to_host16(mgmt->u.auth.auth_transaction);
- if (auth_alg == WLAN_AUTH_OPEN ||
- (auth_alg == WLAN_AUTH_SHARED_KEY && auth_trans != 3))
- do_not_encrypt = 1;
- }
-
- return i802_send_frame(priv, data, len, !do_not_encrypt, flags);
-}
-
-/* Set kernel driver on given frequency (MHz) */
-static int i802_set_freq2(void *priv, struct hostapd_freq_params *freq)
-{
- struct i802_driver_data *drv = priv;
- struct nl_msg *msg;
-
- msg = nlmsg_alloc();
- if (!msg)
- return -1;
-
- drv->last_freq = freq->freq;
- drv->last_freq_ht = freq->ht_enabled;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
- NL80211_CMD_SET_WIPHY, 0);
-
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq->freq);
- if (freq->ht_enabled) {
- switch (freq->sec_channel_offset) {
- case -1:
- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
- NL80211_CHAN_HT40MINUS);
- break;
- case 1:
- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
- NL80211_CHAN_HT40PLUS);
- break;
- default:
- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
- NL80211_CHAN_HT20);
- break;
- }
- }
-
- if (send_and_recv_msgs(drv, msg, NULL, NULL) == 0)
- return 0;
- nla_put_failure:
- return -1;
-}
-
-
-static int i802_set_rts(void *priv, int rts)
-{
- struct i802_driver_data *drv = priv;
- struct iwreq iwr;
-
- memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
- iwr.u.rts.value = rts;
- iwr.u.rts.fixed = 1;
-
- if (ioctl(drv->ioctl_sock, SIOCSIWRTS, &iwr) < 0) {
- perror("ioctl[SIOCSIWRTS]");
- return -1;
- }
-
- return 0;
-}
-
-
-static int i802_get_rts(void *priv, int *rts)
-{
- struct i802_driver_data *drv = priv;
- struct iwreq iwr;
-
- memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
-
- if (ioctl(drv->ioctl_sock, SIOCGIWRTS, &iwr) < 0) {
- perror("ioctl[SIOCGIWRTS]");
- return -1;
- }
-
- *rts = iwr.u.rts.value;
-
- return 0;
-}
-
-
-static int i802_set_frag(void *priv, int frag)
-{
- struct i802_driver_data *drv = priv;
- struct iwreq iwr;
-
- memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
- iwr.u.frag.value = frag;
- iwr.u.frag.fixed = 1;
-
- if (ioctl(drv->ioctl_sock, SIOCSIWFRAG, &iwr) < 0) {
- perror("ioctl[SIOCSIWFRAG]");
- return -1;
- }
-
- return 0;
-}
-
-
-static int i802_get_frag(void *priv, int *frag)
-{
- struct i802_driver_data *drv = priv;
- struct iwreq iwr;
-
- memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
-
- if (ioctl(drv->ioctl_sock, SIOCGIWFRAG, &iwr) < 0) {
- perror("ioctl[SIOCGIWFRAG]");
- return -1;
- }
-
- *frag = iwr.u.frag.value;
-
- return 0;
-}
-
-
-static int i802_set_retry(void *priv, int short_retry, int long_retry)
-{
- struct i802_driver_data *drv = priv;
- struct iwreq iwr;
-
- memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
-
- iwr.u.retry.value = short_retry;
- iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
- if (ioctl(drv->ioctl_sock, SIOCSIWRETRY, &iwr) < 0) {
- perror("ioctl[SIOCSIWRETRY(short)]");
- return -1;
- }
-
- iwr.u.retry.value = long_retry;
- iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
- if (ioctl(drv->ioctl_sock, SIOCSIWRETRY, &iwr) < 0) {
- perror("ioctl[SIOCSIWRETRY(long)]");
- return -1;
- }
-
- return 0;
-}
-
-
-static int i802_get_retry(void *priv, int *short_retry, int *long_retry)
-{
- struct i802_driver_data *drv = priv;
- struct iwreq iwr;
-
- memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
-
- iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
- if (ioctl(drv->ioctl_sock, SIOCGIWRETRY, &iwr) < 0) {
- perror("ioctl[SIOCGIWFRAG(short)]");
- return -1;
- }
- *short_retry = iwr.u.retry.value;
-
- iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
- if (ioctl(drv->ioctl_sock, SIOCGIWRETRY, &iwr) < 0) {
- perror("ioctl[SIOCGIWFRAG(long)]");
- return -1;
- }
- *long_retry = iwr.u.retry.value;
-
- return 0;
-}
-
-
-static int i802_flush(void *priv)
-{
- struct i802_driver_data *drv = priv;
- struct nl_msg *msg;
-
- msg = nlmsg_alloc();
- if (!msg)
- return -1;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_DEL_STATION, 0);
-
- /*
- * XXX: FIX! this needs to flush all VLANs too
- */
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
- if_nametoindex(drv->iface));
-
- return send_and_recv_msgs(drv, msg, NULL, NULL);
- nla_put_failure:
- return -ENOBUFS;
-}
-
-
-static int get_sta_handler(struct nl_msg *msg, void *arg)
-{
- struct nlattr *tb[NL80211_ATTR_MAX + 1];
- struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
- struct hostap_sta_driver_data *data = arg;
- struct nlattr *stats[NL80211_STA_INFO_MAX + 1];
- static struct nla_policy stats_policy[NL80211_STA_INFO_MAX + 1] = {
- [NL80211_STA_INFO_INACTIVE_TIME] = { .type = NLA_U32 },
- [NL80211_STA_INFO_RX_BYTES] = { .type = NLA_U32 },
- [NL80211_STA_INFO_TX_BYTES] = { .type = NLA_U32 },
- [NL80211_STA_INFO_RX_PACKETS] = { .type = NLA_U32 },
- [NL80211_STA_INFO_TX_PACKETS] = { .type = NLA_U32 },
- };
-
- nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
- genlmsg_attrlen(gnlh, 0), NULL);
-
- /*
- * TODO: validate the interface and mac address!
- * Otherwise, there's a race condition as soon as
- * the kernel starts sending station notifications.
- */
-
- if (!tb[NL80211_ATTR_STA_INFO]) {
- wpa_printf(MSG_DEBUG, "sta stats missing!");
- return NL_SKIP;
- }
- if (nla_parse_nested(stats, NL80211_STA_INFO_MAX,
- tb[NL80211_ATTR_STA_INFO],
- stats_policy)) {
- wpa_printf(MSG_DEBUG, "failed to parse nested attributes!");
- return NL_SKIP;
- }
-
- if (stats[NL80211_STA_INFO_INACTIVE_TIME])
- data->inactive_msec =
- nla_get_u32(stats[NL80211_STA_INFO_INACTIVE_TIME]);
- if (stats[NL80211_STA_INFO_RX_BYTES])
- data->rx_bytes = nla_get_u32(stats[NL80211_STA_INFO_RX_BYTES]);
- if (stats[NL80211_STA_INFO_TX_BYTES])
- data->tx_bytes = nla_get_u32(stats[NL80211_STA_INFO_TX_BYTES]);
- if (stats[NL80211_STA_INFO_RX_PACKETS])
- data->rx_packets =
- nla_get_u32(stats[NL80211_STA_INFO_RX_PACKETS]);
- if (stats[NL80211_STA_INFO_TX_PACKETS])
- data->tx_packets =
- nla_get_u32(stats[NL80211_STA_INFO_TX_PACKETS]);
-
- return NL_SKIP;
-}
-
-static int i802_read_sta_data(void *priv, struct hostap_sta_driver_data *data,
- const u8 *addr)
-{
- struct i802_driver_data *drv = priv;
- struct nl_msg *msg;
-
- os_memset(data, 0, sizeof(*data));
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_GET_STATION, 0);
-
- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
-
- return send_and_recv_msgs(drv, msg, get_sta_handler, data);
- nla_put_failure:
- return -ENOBUFS;
-}
-
-
-static int i802_send_eapol(void *priv, const u8 *addr, const u8 *data,
- size_t data_len, int encrypt, const u8 *own_addr)
-{
- struct i802_driver_data *drv = priv;
- struct ieee80211_hdr *hdr;
- size_t len;
- u8 *pos;
- int res;
-#if 0 /* FIX */
- int qos = sta->flags & WLAN_STA_WME;
-#else
- int qos = 0;
-#endif
-
- len = sizeof(*hdr) + (qos ? 2 : 0) + sizeof(rfc1042_header) + 2 +
- data_len;
- hdr = os_zalloc(len);
- if (hdr == NULL) {
- printf("malloc() failed for i802_send_data(len=%lu)\n",
- (unsigned long) len);
- return -1;
- }
-
- hdr->frame_control =
- IEEE80211_FC(WLAN_FC_TYPE_DATA, WLAN_FC_STYPE_DATA);
- hdr->frame_control |= host_to_le16(WLAN_FC_FROMDS);
- if (encrypt)
- hdr->frame_control |= host_to_le16(WLAN_FC_ISWEP);
-#if 0 /* To be enabled if qos determination is added above */
- if (qos) {
- hdr->frame_control |=
- host_to_le16(WLAN_FC_STYPE_QOS_DATA << 4);
- }
-#endif
-
- memcpy(hdr->IEEE80211_DA_FROMDS, addr, ETH_ALEN);
- memcpy(hdr->IEEE80211_BSSID_FROMDS, own_addr, ETH_ALEN);
- memcpy(hdr->IEEE80211_SA_FROMDS, own_addr, ETH_ALEN);
- pos = (u8 *) (hdr + 1);
-
-#if 0 /* To be enabled if qos determination is added above */
- if (qos) {
- /* add an empty QoS header if needed */
- pos[0] = 0;
- pos[1] = 0;
- pos += 2;
- }
-#endif
-
- memcpy(pos, rfc1042_header, sizeof(rfc1042_header));
- pos += sizeof(rfc1042_header);
- WPA_PUT_BE16(pos, ETH_P_PAE);
- pos += 2;
- memcpy(pos, data, data_len);
-
- res = i802_send_frame(drv, (u8 *) hdr, len, encrypt, 0);
- free(hdr);
-
- if (res < 0) {
- perror("i802_send_eapol: send");
- printf("i802_send_eapol - packet len: %lu - failed\n",
- (unsigned long) len);
- }
-
- return res;
-}
-
-
-static int i802_sta_add2(const char *ifname, void *priv,
- struct hostapd_sta_add_params *params)
-{
- struct i802_driver_data *drv = priv;
- struct nl_msg *msg;
- int ret = -ENOBUFS;
-
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_NEW_STATION, 0);
-
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
- if_nametoindex(drv->iface));
- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, params->addr);
- NLA_PUT_U16(msg, NL80211_ATTR_STA_AID, params->aid);
- NLA_PUT(msg, NL80211_ATTR_STA_SUPPORTED_RATES, params->supp_rates_len,
- params->supp_rates);
- NLA_PUT_U16(msg, NL80211_ATTR_STA_LISTEN_INTERVAL,
- params->listen_interval);
-
-#ifdef CONFIG_IEEE80211N
- if (params->ht_capabilities) {
- NLA_PUT(msg, NL80211_ATTR_HT_CAPABILITY,
- params->ht_capabilities->length,
- &params->ht_capabilities->data);
- }
-#endif /* CONFIG_IEEE80211N */
-
- ret = send_and_recv_msgs(drv, msg, NULL, NULL);
- if (ret)
- wpa_printf(MSG_DEBUG, "nl80211: NL80211_CMD_NEW_STATION "
- "result: %d (%s)", ret, strerror(-ret));
- if (ret == -EEXIST)
- ret = 0;
- nla_put_failure:
- return ret;
-}
-
-
-static int i802_sta_remove(void *priv, const u8 *addr)
-{
- struct i802_driver_data *drv = priv;
- struct nl_msg *msg;
- int ret;
-
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_DEL_STATION, 0);
-
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
- if_nametoindex(drv->iface));
- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
-
- ret = send_and_recv_msgs(drv, msg, NULL, NULL);
- if (ret == -ENOENT)
- return 0;
- return ret;
- nla_put_failure:
- return -ENOBUFS;
-}
-
-
-static int i802_sta_set_flags(void *priv, const u8 *addr,
- int total_flags, int flags_or, int flags_and)
-{
- struct i802_driver_data *drv = priv;
- struct nl_msg *msg, *flags = NULL;
-
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- flags = nlmsg_alloc();
- if (!flags) {
- nlmsg_free(msg);
- return -ENOMEM;
- }
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_SET_STATION, 0);
-
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
- if_nametoindex(drv->iface));
- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
-
- if (total_flags & WLAN_STA_AUTHORIZED || !drv->ieee802_1x_active)
- NLA_PUT_FLAG(flags, NL80211_STA_FLAG_AUTHORIZED);
-
- if (total_flags & WLAN_STA_WMM)
- NLA_PUT_FLAG(flags, NL80211_STA_FLAG_WME);
-
- if (total_flags & WLAN_STA_SHORT_PREAMBLE)
- NLA_PUT_FLAG(flags, NL80211_STA_FLAG_SHORT_PREAMBLE);
-
- if (total_flags & WLAN_STA_MFP)
- NLA_PUT_FLAG(flags, NL80211_STA_FLAG_MFP);
-
- if (nla_put_nested(msg, NL80211_ATTR_STA_FLAGS, flags))
- goto nla_put_failure;
-
- nlmsg_free(flags);
-
- return send_and_recv_msgs(drv, msg, NULL, NULL);
- nla_put_failure:
- nlmsg_free(flags);
- return -ENOBUFS;
-}
-
-
-static int i802_set_regulatory_domain(void *priv, unsigned int rd)
-{
- return -1;
-}
-
-
-static int i802_set_tx_queue_params(void *priv, int queue, int aifs,
- int cw_min, int cw_max, int burst_time)
-{
- struct i802_driver_data *drv = priv;
- struct nl_msg *msg;
- struct nlattr *txq, *params;
-
- msg = nlmsg_alloc();
- if (!msg)
- return -1;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_SET_WIPHY, 0);
-
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
-
- txq = nla_nest_start(msg, NL80211_ATTR_WIPHY_TXQ_PARAMS);
- if (!txq)
- goto nla_put_failure;
-
- /* We are only sending parameters for a single TXQ at a time */
- params = nla_nest_start(msg, 1);
- if (!params)
- goto nla_put_failure;
-
- NLA_PUT_U8(msg, NL80211_TXQ_ATTR_QUEUE, queue);
- /* Burst time is configured in units of 0.1 msec and TXOP parameter in
- * 32 usec, so need to convert the value here. */
- NLA_PUT_U16(msg, NL80211_TXQ_ATTR_TXOP, (burst_time * 100 + 16) / 32);
- NLA_PUT_U16(msg, NL80211_TXQ_ATTR_CWMIN, cw_min);
- NLA_PUT_U16(msg, NL80211_TXQ_ATTR_CWMAX, cw_max);
- NLA_PUT_U8(msg, NL80211_TXQ_ATTR_AIFS, aifs);
-
- nla_nest_end(msg, params);
-
- nla_nest_end(msg, txq);
-
- if (send_and_recv_msgs(drv, msg, NULL, NULL) == 0)
- return 0;
- nla_put_failure:
- return -1;
-}
-
-
-static void nl80211_remove_iface(struct i802_driver_data *drv, int ifidx)
-{
- struct nl_msg *msg;
-
- /* stop listening for EAPOL on this interface */
- del_ifidx(drv, ifidx);
-
- msg = nlmsg_alloc();
- if (!msg)
- goto nla_put_failure;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_DEL_INTERFACE, 0);
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifidx);
-
- if (send_and_recv_msgs(drv, msg, NULL, NULL) == 0)
- return;
- nla_put_failure:
- printf("Failed to remove interface.\n");
-}
-
-
-static int nl80211_create_iface(struct i802_driver_data *drv,
- const char *ifname,
- enum nl80211_iftype iftype,
- const u8 *addr)
-{
- struct nl_msg *msg, *flags = NULL;
- int ifidx;
- struct ifreq ifreq;
- struct iwreq iwr;
- int ret = -ENOBUFS;
-
- msg = nlmsg_alloc();
- if (!msg)
- return -1;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_NEW_INTERFACE, 0);
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
- if_nametoindex(drv->hapd->conf->iface));
- NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, ifname);
- NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, iftype);
-
- if (iftype == NL80211_IFTYPE_MONITOR) {
- int err;
-
- flags = nlmsg_alloc();
- if (!flags)
- goto nla_put_failure;
-
- NLA_PUT_FLAG(flags, NL80211_MNTR_FLAG_COOK_FRAMES);
-
- err = nla_put_nested(msg, NL80211_ATTR_MNTR_FLAGS, flags);
-
- nlmsg_free(flags);
-
- if (err)
- goto nla_put_failure;
- }
-
- ret = send_and_recv_msgs(drv, msg, NULL, NULL);
- if (ret) {
- nla_put_failure:
- printf("Failed to create interface %s.\n", ifname);
- return ret;
- }
-
- ifidx = if_nametoindex(ifname);
-
- if (ifidx <= 0)
- return -1;
-
- /* start listening for EAPOL on this interface */
- add_ifidx(drv, ifidx);
-
- if (addr) {
- switch (iftype) {
- case NL80211_IFTYPE_AP:
- os_strlcpy(ifreq.ifr_name, ifname, IFNAMSIZ);
- memcpy(ifreq.ifr_hwaddr.sa_data, addr, ETH_ALEN);
- ifreq.ifr_hwaddr.sa_family = ARPHRD_ETHER;
-
- if (ioctl(drv->ioctl_sock, SIOCSIFHWADDR, &ifreq)) {
- nl80211_remove_iface(drv, ifidx);
- return -1;
- }
- break;
- case NL80211_IFTYPE_WDS:
- memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, ifname, IFNAMSIZ);
- iwr.u.addr.sa_family = ARPHRD_ETHER;
- memcpy(iwr.u.addr.sa_data, addr, ETH_ALEN);
- if (ioctl(drv->ioctl_sock, SIOCSIWAP, &iwr))
- return -1;
- break;
- default:
- /* nothing */
- break;
- }
- }
-
- return ifidx;
-}
-
-
-static int i802_bss_add(void *priv, const char *ifname, const u8 *bssid)
-{
- int ifidx;
-
- /*
- * The kernel supports that when the low-level driver does,
- * but we currently don't because we need per-BSS data that
- * currently we can't handle easily.
- */
- return -1;
-
- ifidx = nl80211_create_iface(priv, ifname, NL80211_IFTYPE_AP, bssid);
- if (ifidx < 0)
- return -1;
- if (hostapd_set_iface_flags(priv, ifname, 1)) {
- nl80211_remove_iface(priv, ifidx);
- return -1;
- }
- return 0;
-}
-
-
-static int i802_bss_remove(void *priv, const char *ifname)
-{
- nl80211_remove_iface(priv, if_nametoindex(ifname));
- return 0;
-}
-
-
-static int i802_set_beacon(const char *iface, void *priv,
- u8 *head, size_t head_len,
- u8 *tail, size_t tail_len)
-{
- struct i802_driver_data *drv = priv;
- struct nl_msg *msg;
- u8 cmd = NL80211_CMD_NEW_BEACON;
- int ret;
-
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- if (drv->beacon_set)
- cmd = NL80211_CMD_SET_BEACON;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, cmd, 0);
- NLA_PUT(msg, NL80211_ATTR_BEACON_HEAD, head_len, head);
- NLA_PUT(msg, NL80211_ATTR_BEACON_TAIL, tail_len, tail);
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
- NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL, drv->beacon_int);
-
- if (!drv->dtim_period)
- drv->dtim_period = 2;
- NLA_PUT_U32(msg, NL80211_ATTR_DTIM_PERIOD, drv->dtim_period);
-
- ret = send_and_recv_msgs(drv, msg, NULL, NULL);
- if (!ret)
- drv->beacon_set = 1;
- return ret;
- nla_put_failure:
- return -ENOBUFS;
-}
-
-
-static int i802_del_beacon(struct i802_driver_data *drv)
-{
- struct nl_msg *msg;
-
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_DEL_BEACON, 0);
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
-
- return send_and_recv_msgs(drv, msg, NULL, NULL);
- nla_put_failure:
- return -ENOBUFS;
-}
-
-
-static int i802_set_ieee8021x(const char *ifname, void *priv, int enabled)
-{
- struct i802_driver_data *drv = priv;
-
- /*
- * FIXME: This needs to be per interface (BSS)
- */
- drv->ieee802_1x_active = enabled;
- return 0;
-}
-
-
-static int i802_set_privacy(const char *ifname, void *priv, int enabled)
-{
- struct i802_driver_data *drv = priv;
- struct iwreq iwr;
-
- memset(&iwr, 0, sizeof(iwr));
-
- os_strlcpy(iwr.ifr_name, ifname, IFNAMSIZ);
- iwr.u.param.flags = IW_AUTH_PRIVACY_INVOKED;
- iwr.u.param.value = enabled;
-
- ioctl(drv->ioctl_sock, SIOCSIWAUTH, &iwr);
-
- /* ignore errors, the kernel/driver might not care */
- return 0;
-}
-
-
-static int i802_set_internal_bridge(void *priv, int value)
-{
- return -1;
-}
-
-
-static int i802_set_beacon_int(void *priv, int value)
-{
- struct i802_driver_data *drv = priv;
- struct nl_msg *msg;
-
- drv->beacon_int = value;
-
- if (!drv->beacon_set)
- return 0;
-
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_SET_BEACON, 0);
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
-
- NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL, value);
-
- return send_and_recv_msgs(drv, msg, NULL, NULL);
- nla_put_failure:
- return -ENOBUFS;
-}
-
-
-static int i802_set_dtim_period(const char *iface, void *priv, int value)
-{
- struct i802_driver_data *drv = priv;
- struct nl_msg *msg;
-
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_SET_BEACON, 0);
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
-
- drv->dtim_period = value;
- NLA_PUT_U32(msg, NL80211_ATTR_DTIM_PERIOD, drv->dtim_period);
-
- return send_and_recv_msgs(drv, msg, NULL, NULL);
- nla_put_failure:
- return -ENOBUFS;
-}
-
-
-static int i802_set_bss(void *priv, int cts, int preamble, int slot)
-{
- struct i802_driver_data *drv = priv;
- struct nl_msg *msg;
-
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
- NL80211_CMD_SET_BSS, 0);
-
- if (cts >= 0)
- NLA_PUT_U8(msg, NL80211_ATTR_BSS_CTS_PROT, cts);
- if (preamble >= 0)
- NLA_PUT_U8(msg, NL80211_ATTR_BSS_SHORT_PREAMBLE, preamble);
- if (slot >= 0)
- NLA_PUT_U8(msg, NL80211_ATTR_BSS_SHORT_SLOT_TIME, slot);
-
- /* TODO: multi-BSS support */
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
-
- return send_and_recv_msgs(drv, msg, NULL, NULL);
- nla_put_failure:
- return -ENOBUFS;
-}
-
-
-static int i802_set_cts_protect(void *priv, int value)
-{
- return i802_set_bss(priv, value, -1, -1);
-}
-
-
-static int i802_set_preamble(void *priv, int value)
-{
- return i802_set_bss(priv, -1, value, -1);
-}
-
-
-static int i802_set_short_slot_time(void *priv, int value)
-{
- return i802_set_bss(priv, -1, -1, value);
-}
-
-
-static enum nl80211_iftype i802_if_type(enum hostapd_driver_if_type type)
-{
- switch (type) {
- case HOSTAPD_IF_VLAN:
- return NL80211_IFTYPE_AP_VLAN;
- case HOSTAPD_IF_WDS:
- return NL80211_IFTYPE_WDS;
- }
- return -1;
-}
-
-
-static int i802_if_add(const char *iface, void *priv,
- enum hostapd_driver_if_type type, char *ifname,
- const u8 *addr)
-{
- if (nl80211_create_iface(priv, ifname, i802_if_type(type), addr) < 0)
- return -1;
- return 0;
-}
-
-
-static int i802_if_update(void *priv, enum hostapd_driver_if_type type,
- char *ifname, const u8 *addr)
-{
- /* unused at the moment */
- return -1;
-}
-
-
-static int i802_if_remove(void *priv, enum hostapd_driver_if_type type,
- const char *ifname, const u8 *addr)
-{
- nl80211_remove_iface(priv, if_nametoindex(ifname));
- return 0;
-}
-
-
-struct phy_info_arg {
- u16 *num_modes;
- struct hostapd_hw_modes *modes;
-};
-
-static int phy_info_handler(struct nl_msg *msg, void *arg)
-{
- struct nlattr *tb_msg[NL80211_ATTR_MAX + 1];
- struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
- struct phy_info_arg *phy_info = arg;
-
- struct nlattr *tb_band[NL80211_BAND_ATTR_MAX + 1];
-
- struct nlattr *tb_freq[NL80211_FREQUENCY_ATTR_MAX + 1];
- static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
- [NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 },
- [NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG },
- [NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG },
- [NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
- [NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG },
- [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 },
- };
-
- struct nlattr *tb_rate[NL80211_BITRATE_ATTR_MAX + 1];
- static struct nla_policy rate_policy[NL80211_BITRATE_ATTR_MAX + 1] = {
- [NL80211_BITRATE_ATTR_RATE] = { .type = NLA_U32 },
- [NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE] = { .type = NLA_FLAG },
- };
-
- struct nlattr *nl_band;
- struct nlattr *nl_freq;
- struct nlattr *nl_rate;
- int rem_band, rem_freq, rem_rate;
- struct hostapd_hw_modes *mode;
- int idx, mode_is_set;
-
- nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
- genlmsg_attrlen(gnlh, 0), NULL);
-
- if (!tb_msg[NL80211_ATTR_WIPHY_BANDS])
- return NL_SKIP;
-
- nla_for_each_nested(nl_band, tb_msg[NL80211_ATTR_WIPHY_BANDS], rem_band) {
- mode = realloc(phy_info->modes, (*phy_info->num_modes + 1) * sizeof(*mode));
- if (!mode)
- return NL_SKIP;
- phy_info->modes = mode;
-
- mode_is_set = 0;
-
- mode = &phy_info->modes[*(phy_info->num_modes)];
- memset(mode, 0, sizeof(*mode));
- *(phy_info->num_modes) += 1;
-
- nla_parse(tb_band, NL80211_BAND_ATTR_MAX, nla_data(nl_band),
- nla_len(nl_band), NULL);
-
- if (tb_band[NL80211_BAND_ATTR_HT_CAPA]) {
- mode->ht_capab = nla_get_u16(
- tb_band[NL80211_BAND_ATTR_HT_CAPA]);
- }
-
- nla_for_each_nested(nl_freq, tb_band[NL80211_BAND_ATTR_FREQS], rem_freq) {
- nla_parse(tb_freq, NL80211_FREQUENCY_ATTR_MAX, nla_data(nl_freq),
- nla_len(nl_freq), freq_policy);
- if (!tb_freq[NL80211_FREQUENCY_ATTR_FREQ])
- continue;
- mode->num_channels++;
- }
-
- mode->channels = calloc(mode->num_channels, sizeof(struct hostapd_channel_data));
- if (!mode->channels)
- return NL_SKIP;
-
- idx = 0;
-
- nla_for_each_nested(nl_freq, tb_band[NL80211_BAND_ATTR_FREQS], rem_freq) {
- nla_parse(tb_freq, NL80211_FREQUENCY_ATTR_MAX, nla_data(nl_freq),
- nla_len(nl_freq), freq_policy);
- if (!tb_freq[NL80211_FREQUENCY_ATTR_FREQ])
- continue;
-
- mode->channels[idx].freq = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_FREQ]);
- mode->channels[idx].flag = 0;
-
- if (!mode_is_set) {
- /* crude heuristic */
- if (mode->channels[idx].freq < 4000)
- mode->mode = HOSTAPD_MODE_IEEE80211B;
- else
- mode->mode = HOSTAPD_MODE_IEEE80211A;
- mode_is_set = 1;
- }
-
- /* crude heuristic */
- if (mode->channels[idx].freq < 4000)
- if (mode->channels[idx].freq == 2484)
- mode->channels[idx].chan = 14;
- else
- mode->channels[idx].chan = (mode->channels[idx].freq - 2407) / 5;
- else
- mode->channels[idx].chan = mode->channels[idx].freq/5 - 1000;
-
- if (tb_freq[NL80211_FREQUENCY_ATTR_DISABLED])
- mode->channels[idx].flag |=
- HOSTAPD_CHAN_DISABLED;
- if (tb_freq[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN])
- mode->channels[idx].flag |=
- HOSTAPD_CHAN_PASSIVE_SCAN;
- if (tb_freq[NL80211_FREQUENCY_ATTR_NO_IBSS])
- mode->channels[idx].flag |=
- HOSTAPD_CHAN_NO_IBSS;
- if (tb_freq[NL80211_FREQUENCY_ATTR_RADAR])
- mode->channels[idx].flag |=
- HOSTAPD_CHAN_RADAR;
-
- if (tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER] &&
- !tb_freq[NL80211_FREQUENCY_ATTR_DISABLED])
- mode->channels[idx].max_tx_power =
- nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER]) / 100;
-
- idx++;
- }
-
- nla_for_each_nested(nl_rate, tb_band[NL80211_BAND_ATTR_RATES], rem_rate) {
- nla_parse(tb_rate, NL80211_BITRATE_ATTR_MAX, nla_data(nl_rate),
- nla_len(nl_rate), rate_policy);
- if (!tb_rate[NL80211_BITRATE_ATTR_RATE])
- continue;
- mode->num_rates++;
- }
-
- mode->rates = calloc(mode->num_rates, sizeof(struct hostapd_rate_data));
- if (!mode->rates)
- return NL_SKIP;
-
- idx = 0;
-
- nla_for_each_nested(nl_rate, tb_band[NL80211_BAND_ATTR_RATES], rem_rate) {
- nla_parse(tb_rate, NL80211_BITRATE_ATTR_MAX, nla_data(nl_rate),
- nla_len(nl_rate), rate_policy);
- if (!tb_rate[NL80211_BITRATE_ATTR_RATE])
- continue;
- mode->rates[idx].rate = nla_get_u32(tb_rate[NL80211_BITRATE_ATTR_RATE]);
-
- /* crude heuristic */
- if (mode->mode == HOSTAPD_MODE_IEEE80211B &&
- mode->rates[idx].rate > 200)
- mode->mode = HOSTAPD_MODE_IEEE80211G;
-
- if (tb_rate[NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE])
- mode->rates[idx].flags |= HOSTAPD_RATE_PREAMBLE2;
-
- idx++;
- }
- }
-
- return NL_SKIP;
-}
-
-static struct hostapd_hw_modes *i802_add_11b(struct hostapd_hw_modes *modes,
- u16 *num_modes)
-{
- u16 m;
- struct hostapd_hw_modes *mode11g = NULL, *nmodes, *mode;
- int i, mode11g_idx = -1;
-
- /* If only 802.11g mode is included, use it to construct matching
- * 802.11b mode data. */
-
- for (m = 0; m < *num_modes; m++) {
- if (modes[m].mode == HOSTAPD_MODE_IEEE80211B)
- return modes; /* 802.11b already included */
- if (modes[m].mode == HOSTAPD_MODE_IEEE80211G)
- mode11g_idx = m;
- }
-
- if (mode11g_idx < 0)
- return modes; /* 2.4 GHz band not supported at all */
-
- nmodes = os_realloc(modes, (*num_modes + 1) * sizeof(*nmodes));
- if (nmodes == NULL)
- return modes; /* Could not add 802.11b mode */
-
- mode = &nmodes[*num_modes];
- os_memset(mode, 0, sizeof(*mode));
- (*num_modes)++;
- modes = nmodes;
-
- mode->mode = HOSTAPD_MODE_IEEE80211B;
-
- mode11g = &modes[mode11g_idx];
- mode->num_channels = mode11g->num_channels;
- mode->channels = os_malloc(mode11g->num_channels *
- sizeof(struct hostapd_channel_data));
- if (mode->channels == NULL) {
- (*num_modes)--;
- return modes; /* Could not add 802.11b mode */
- }
- os_memcpy(mode->channels, mode11g->channels,
- mode11g->num_channels * sizeof(struct hostapd_channel_data));
-
- mode->num_rates = 0;
- mode->rates = os_malloc(4 * sizeof(struct hostapd_rate_data));
- if (mode->rates == NULL) {
- os_free(mode->channels);
- (*num_modes)--;
- return modes; /* Could not add 802.11b mode */
- }
-
- for (i = 0; i < mode11g->num_rates; i++) {
- if (mode11g->rates[i].rate > 110 ||
- mode11g->rates[i].flags &
- (HOSTAPD_RATE_ERP | HOSTAPD_RATE_OFDM))
- continue;
- mode->rates[mode->num_rates] = mode11g->rates[i];
- mode->num_rates++;
- if (mode->num_rates == 4)
- break;
- }
-
- if (mode->num_rates == 0) {
- os_free(mode->channels);
- os_free(mode->rates);
- (*num_modes)--;
- return modes; /* No 802.11b rates */
- }
-
- wpa_printf(MSG_DEBUG, "nl80211: Added 802.11b mode based on 802.11g "
- "information");
-
- return modes;
-}
-
-static struct hostapd_hw_modes *i802_get_hw_feature_data(void *priv,
- u16 *num_modes,
- u16 *flags)
-{
- struct i802_driver_data *drv = priv;
- struct nl_msg *msg;
- struct phy_info_arg result = {
- .num_modes = num_modes,
- .modes = NULL,
- };
-
- *num_modes = 0;
- *flags = 0;
-
- msg = nlmsg_alloc();
- if (!msg)
- return NULL;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_GET_WIPHY, 0);
-
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
-
- if (send_and_recv_msgs(drv, msg, phy_info_handler, &result) == 0)
- return i802_add_11b(result.modes, num_modes);
- nla_put_failure:
- return NULL;
-}
-
-
-static int i802_set_sta_vlan(void *priv, const u8 *addr,
- const char *ifname, int vlan_id)
-{
- struct i802_driver_data *drv = priv;
- struct nl_msg *msg;
-
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_SET_STATION, 0);
-
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
- if_nametoindex(drv->iface));
- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
- if_nametoindex(ifname));
-
- return send_and_recv_msgs(drv, msg, NULL, NULL);
- nla_put_failure:
- return -ENOBUFS;
-}
-
-
-static int i802_set_country(void *priv, const char *country)
-{
- struct i802_driver_data *drv = priv;
- struct nl_msg *msg;
- char alpha2[3];
-
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_REQ_SET_REG, 0);
-
- alpha2[0] = country[0];
- alpha2[1] = country[1];
- alpha2[2] = '\0';
- NLA_PUT_STRING(msg, NL80211_ATTR_REG_ALPHA2, alpha2);
-
- return send_and_recv_msgs(drv, msg, NULL, NULL);
- nla_put_failure:
- return -ENOBUFS;
-}
-
-
-static void handle_unknown_sta(struct hostapd_data *hapd, u8 *ta)
-{
- struct sta_info *sta;
-
- sta = ap_get_sta(hapd, ta);
- if (!sta || !(sta->flags & WLAN_STA_ASSOC)) {
- printf("Data/PS-poll frame from not associated STA "
- MACSTR "\n", MAC2STR(ta));
- if (sta && (sta->flags & WLAN_STA_AUTH))
- hostapd_sta_disassoc(
- hapd, ta,
- WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
- else
- hostapd_sta_deauth(
- hapd, ta,
- WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
- }
-}
-
-
-static void handle_tx_callback(struct hostapd_data *hapd, u8 *buf, size_t len,
- int ok)
-{
- struct ieee80211_hdr *hdr;
- u16 fc, type, stype;
- struct sta_info *sta;
-
- hdr = (struct ieee80211_hdr *) buf;
- fc = le_to_host16(hdr->frame_control);
-
- type = WLAN_FC_GET_TYPE(fc);
- stype = WLAN_FC_GET_STYPE(fc);
-
- switch (type) {
- case WLAN_FC_TYPE_MGMT:
- wpa_printf(MSG_DEBUG, "MGMT (TX callback) %s",
- ok ? "ACK" : "fail");
- ieee802_11_mgmt_cb(hapd, buf, len, stype, ok);
- break;
- case WLAN_FC_TYPE_CTRL:
- wpa_printf(MSG_DEBUG, "CTRL (TX callback) %s",
- ok ? "ACK" : "fail");
- break;
- case WLAN_FC_TYPE_DATA:
- sta = ap_get_sta(hapd, hdr->addr1);
- if (sta && sta->flags & WLAN_STA_PENDING_POLL) {
- wpa_printf(MSG_DEBUG, "STA " MACSTR " %s pending "
- "activity poll", MAC2STR(sta->addr),
- ok ? "ACKed" : "did not ACK");
- if (ok)
- sta->flags &= ~WLAN_STA_PENDING_POLL;
- }
- if (sta)
- ieee802_1x_tx_status(hapd, sta, buf, len, ok);
- break;
- default:
- printf("unknown TX callback frame type %d\n", type);
- break;
- }
-}
-
-
-static void handle_frame(struct hostapd_iface *iface, u8 *buf, size_t len,
- struct hostapd_frame_info *hfi,
- enum ieee80211_msg_type msg_type)
-{
- struct ieee80211_hdr *hdr;
- u16 fc, type, stype;
- size_t data_len = len;
- struct hostapd_data *hapd = NULL;
- int broadcast_bssid = 0;
- size_t i;
- u8 *bssid;
-
- /*
- * PS-Poll frames are 16 bytes. All other frames are
- * 24 bytes or longer.
- */
- if (len < 16)
- return;
-
- hdr = (struct ieee80211_hdr *) buf;
- fc = le_to_host16(hdr->frame_control);
-
- type = WLAN_FC_GET_TYPE(fc);
- stype = WLAN_FC_GET_STYPE(fc);
-
- switch (type) {
- case WLAN_FC_TYPE_DATA:
- if (len < 24)
- return;
- switch (fc & (WLAN_FC_FROMDS | WLAN_FC_TODS)) {
- case WLAN_FC_TODS:
- bssid = hdr->addr1;
- break;
- case WLAN_FC_FROMDS:
- bssid = hdr->addr2;
- break;
- default:
- /* discard */
- return;
- }
- break;
- case WLAN_FC_TYPE_CTRL:
- /* discard non-ps-poll frames */
- if (stype != WLAN_FC_STYPE_PSPOLL)
- return;
- bssid = hdr->addr1;
- break;
- case WLAN_FC_TYPE_MGMT:
- bssid = hdr->addr3;
- break;
- default:
- /* discard */
- return;
- }
-
- /* find interface frame belongs to */
- for (i = 0; i < iface->num_bss; i++) {
- if (memcmp(bssid, iface->bss[i]->own_addr, ETH_ALEN) == 0) {
- hapd = iface->bss[i];
- break;
- }
- }
-
- if (hapd == NULL) {
- hapd = iface->bss[0];
-
- if (bssid[0] != 0xff || bssid[1] != 0xff ||
- bssid[2] != 0xff || bssid[3] != 0xff ||
- bssid[4] != 0xff || bssid[5] != 0xff) {
- /*
- * Unknown BSSID - drop frame if this is not from
- * passive scanning or a beacon (at least ProbeReq
- * frames to other APs may be allowed through RX
- * filtering in the wlan hw/driver)
- */
- if ((type != WLAN_FC_TYPE_MGMT ||
- stype != WLAN_FC_STYPE_BEACON))
- return;
- } else
- broadcast_bssid = 1;
- }
-
- switch (msg_type) {
- case ieee80211_msg_normal:
- /* continue processing */
- break;
- case ieee80211_msg_tx_callback_ack:
- handle_tx_callback(hapd, buf, data_len, 1);
- return;
- case ieee80211_msg_tx_callback_fail:
- handle_tx_callback(hapd, buf, data_len, 0);
- return;
- }
-
- switch (type) {
- case WLAN_FC_TYPE_MGMT:
- if (stype != WLAN_FC_STYPE_BEACON &&
- stype != WLAN_FC_STYPE_PROBE_REQ)
- wpa_printf(MSG_MSGDUMP, "MGMT");
- if (broadcast_bssid) {
- for (i = 0; i < iface->num_bss; i++)
- ieee802_11_mgmt(iface->bss[i], buf, data_len,
- stype, hfi);
- } else
- ieee802_11_mgmt(hapd, buf, data_len, stype, hfi);
- break;
- case WLAN_FC_TYPE_CTRL:
- /* can only get here with PS-Poll frames */
- wpa_printf(MSG_DEBUG, "CTRL");
- handle_unknown_sta(hapd, hdr->addr2);
- break;
- case WLAN_FC_TYPE_DATA:
- handle_unknown_sta(hapd, hdr->addr2);
- break;
- }
-}
-
-
-static void handle_eapol(int sock, void *eloop_ctx, void *sock_ctx)
-{
- struct i802_driver_data *drv = eloop_ctx;
- struct hostapd_data *hapd = drv->hapd;
- struct sockaddr_ll lladdr;
- unsigned char buf[3000];
- int len;
- socklen_t fromlen = sizeof(lladdr);
-
- len = recvfrom(sock, buf, sizeof(buf), 0,
- (struct sockaddr *)&lladdr, &fromlen);
- if (len < 0) {
- perror("recv");
- return;
- }
-
- if (have_ifidx(drv, lladdr.sll_ifindex))
- ieee802_1x_receive(hapd, lladdr.sll_addr, buf, len);
-}
-
-
-static void handle_monitor_read(int sock, void *eloop_ctx, void *sock_ctx)
-{
- struct i802_driver_data *drv = eloop_ctx;
- int len;
- unsigned char buf[3000];
- struct hostapd_data *hapd = drv->hapd;
- struct ieee80211_radiotap_iterator iter;
- int ret;
- struct hostapd_frame_info hfi;
- int injected = 0, failed = 0, msg_type, rxflags = 0;
-
- len = recv(sock, buf, sizeof(buf), 0);
- if (len < 0) {
- perror("recv");
- return;
- }
-
- if (ieee80211_radiotap_iterator_init(&iter, (void*)buf, len)) {
- printf("received invalid radiotap frame\n");
- return;
- }
-
- memset(&hfi, 0, sizeof(hfi));
-
- while (1) {
- ret = ieee80211_radiotap_iterator_next(&iter);
- if (ret == -ENOENT)
- break;
- if (ret) {
- printf("received invalid radiotap frame (%d)\n", ret);
- return;
- }
- switch (iter.this_arg_index) {
- case IEEE80211_RADIOTAP_FLAGS:
- if (*iter.this_arg & IEEE80211_RADIOTAP_F_FCS)
- len -= 4;
- break;
- case IEEE80211_RADIOTAP_RX_FLAGS:
- rxflags = 1;
- break;
- case IEEE80211_RADIOTAP_TX_FLAGS:
- injected = 1;
- failed = le_to_host16((*(uint16_t *) iter.this_arg)) &
- IEEE80211_RADIOTAP_F_TX_FAIL;
- break;
- case IEEE80211_RADIOTAP_DATA_RETRIES:
- break;
- case IEEE80211_RADIOTAP_CHANNEL:
- /* TODO convert from freq/flags to channel number
- hfi.channel = XXX;
- hfi.phytype = XXX;
- */
- break;
- case IEEE80211_RADIOTAP_RATE:
- hfi.datarate = *iter.this_arg * 5;
- break;
- case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
- hfi.ssi_signal = *iter.this_arg;
- break;
- }
- }
-
- if (rxflags && injected)
- return;
-
- if (!injected)
- msg_type = ieee80211_msg_normal;
- else if (failed)
- msg_type = ieee80211_msg_tx_callback_fail;
- else
- msg_type = ieee80211_msg_tx_callback_ack;
-
- handle_frame(hapd->iface, buf + iter.max_length,
- len - iter.max_length, &hfi, msg_type);
-}
-
-
-/*
- * we post-process the filter code later and rewrite
- * this to the offset to the last instruction
- */
-#define PASS 0xFF
-#define FAIL 0xFE
-
-static struct sock_filter msock_filter_insns[] = {
- /*
- * do a little-endian load of the radiotap length field
- */
- /* load lower byte into A */
- BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2),
- /* put it into X (== index register) */
- BPF_STMT(BPF_MISC| BPF_TAX, 0),
- /* load upper byte into A */
- BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 3),
- /* left-shift it by 8 */
- BPF_STMT(BPF_ALU | BPF_LSH | BPF_K, 8),
- /* or with X */
- BPF_STMT(BPF_ALU | BPF_OR | BPF_X, 0),
- /* put result into X */
- BPF_STMT(BPF_MISC| BPF_TAX, 0),
-
- /*
- * Allow management frames through, this also gives us those
- * management frames that we sent ourselves with status
- */
- /* load the lower byte of the IEEE 802.11 frame control field */
- BPF_STMT(BPF_LD | BPF_B | BPF_IND, 0),
- /* mask off frame type and version */
- BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0xF),
- /* accept frame if it's both 0, fall through otherwise */
- BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, PASS, 0),
-
- /*
- * TODO: add a bit to radiotap RX flags that indicates
- * that the sending station is not associated, then
- * add a filter here that filters on our DA and that flag
- * to allow us to deauth frames to that bad station.
- *
- * Not a regression -- we didn't do it before either.
- */
-
-#if 0
- /*
- * drop non-data frames, WDS frames
- */
- /* load the lower byte of the frame control field */
- BPF_STMT(BPF_LD | BPF_B | BPF_IND, 0),
- /* mask off QoS bit */
- BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0x0c),
- /* drop non-data frames */
- BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 8, 0, FAIL),
- /* load the upper byte of the frame control field */
- BPF_STMT(BPF_LD | BPF_B | BPF_IND, 0),
- /* mask off toDS/fromDS */
- BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0x03),
- /* drop WDS frames */
- BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 3, FAIL, 0),
-#endif
-
- /*
- * add header length to index
- */
- /* load the lower byte of the frame control field */
- BPF_STMT(BPF_LD | BPF_B | BPF_IND, 0),
- /* mask off QoS bit */
- BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0x80),
- /* right shift it by 6 to give 0 or 2 */
- BPF_STMT(BPF_ALU | BPF_RSH | BPF_K, 6),
- /* add data frame header length */
- BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 24),
- /* add index, was start of 802.11 header */
- BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
- /* move to index, now start of LL header */
- BPF_STMT(BPF_MISC | BPF_TAX, 0),
-
- /*
- * Accept empty data frames, we use those for
- * polling activity.
- */
- BPF_STMT(BPF_LD | BPF_W | BPF_LEN, 0),
- BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_X, 0, PASS, 0),
-
- /*
- * Accept EAPOL frames
- */
- BPF_STMT(BPF_LD | BPF_W | BPF_IND, 0),
- BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0xAAAA0300, 0, FAIL),
- BPF_STMT(BPF_LD | BPF_W | BPF_IND, 4),
- BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x0000888E, PASS, FAIL),
-
- /* keep these last two statements or change the code below */
- /* return 0 == "DROP" */
- BPF_STMT(BPF_RET | BPF_K, 0),
- /* return ~0 == "keep all" */
- BPF_STMT(BPF_RET | BPF_K, ~0),
-};
-
-static struct sock_fprog msock_filter = {
- .len = sizeof(msock_filter_insns)/sizeof(msock_filter_insns[0]),
- .filter = msock_filter_insns,
-};
-
-
-static int add_monitor_filter(int s)
-{
- int idx;
-
- /* rewrite all PASS/FAIL jump offsets */
- for (idx = 0; idx < msock_filter.len; idx++) {
- struct sock_filter *insn = &msock_filter_insns[idx];
-
- if (BPF_CLASS(insn->code) == BPF_JMP) {
- if (insn->code == (BPF_JMP|BPF_JA)) {
- if (insn->k == PASS)
- insn->k = msock_filter.len - idx - 2;
- else if (insn->k == FAIL)
- insn->k = msock_filter.len - idx - 3;
- }
-
- if (insn->jt == PASS)
- insn->jt = msock_filter.len - idx - 2;
- else if (insn->jt == FAIL)
- insn->jt = msock_filter.len - idx - 3;
-
- if (insn->jf == PASS)
- insn->jf = msock_filter.len - idx - 2;
- else if (insn->jf == FAIL)
- insn->jf = msock_filter.len - idx - 3;
- }
- }
-
- if (setsockopt(s, SOL_SOCKET, SO_ATTACH_FILTER,
- &msock_filter, sizeof(msock_filter))) {
- perror("SO_ATTACH_FILTER");
- return -1;
- }
-
- return 0;
-}
-
-
-static int nl80211_create_monitor_interface(struct i802_driver_data *drv)
-{
- char buf[IFNAMSIZ];
- struct sockaddr_ll ll;
- int optval;
- socklen_t optlen;
-
- snprintf(buf, IFNAMSIZ, "mon.%s", drv->iface);
- buf[IFNAMSIZ - 1] = '\0';
-
- drv->monitor_ifidx =
- nl80211_create_iface(drv, buf, NL80211_IFTYPE_MONITOR, NULL);
-
- if (drv->monitor_ifidx < 0)
- return -1;
-
- if (hostapd_set_iface_flags(drv, buf, 1))
- goto error;
-
- memset(&ll, 0, sizeof(ll));
- ll.sll_family = AF_PACKET;
- ll.sll_ifindex = drv->monitor_ifidx;
- drv->monitor_sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
- if (drv->monitor_sock < 0) {
- perror("socket[PF_PACKET,SOCK_RAW]");
- goto error;
- }
-
- if (add_monitor_filter(drv->monitor_sock)) {
- wpa_printf(MSG_INFO, "Failed to set socket filter for monitor "
- "interface; do filtering in user space");
- /* This works, but will cost in performance. */
- }
-
- if (bind(drv->monitor_sock, (struct sockaddr *) &ll,
- sizeof(ll)) < 0) {
- perror("monitor socket bind");
- goto error;
- }
-
- optlen = sizeof(optval);
- optval = 20;
- if (setsockopt
- (drv->monitor_sock, SOL_SOCKET, SO_PRIORITY, &optval, optlen)) {
- perror("Failed to set socket priority");
- goto error;
- }
-
- if (eloop_register_read_sock(drv->monitor_sock, handle_monitor_read,
- drv, NULL)) {
- printf("Could not register monitor read socket\n");
- goto error;
- }
-
- return 0;
- error:
- nl80211_remove_iface(drv, drv->monitor_ifidx);
- return -1;
-}
-
-
-static int nl80211_set_master_mode(struct i802_driver_data *drv,
- const char *ifname)
-{
- struct nl_msg *msg;
- int ret = -ENOBUFS;
-
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
- 0, NL80211_CMD_SET_INTERFACE, 0);
- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
- if_nametoindex(ifname));
- NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, NL80211_IFTYPE_AP);
-
- ret = send_and_recv_msgs(drv, msg, NULL, NULL);
- if (!ret)
- return 0;
- nla_put_failure:
- wpa_printf(MSG_ERROR, "Failed to set interface %s to master "
- "mode.", ifname);
- return ret;
-}
-
-
-static int i802_init_sockets(struct i802_driver_data *drv, const u8 *bssid)
-{
- struct ifreq ifr;
- struct sockaddr_ll addr;
-
- drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
- if (drv->ioctl_sock < 0) {
- perror("socket[PF_INET,SOCK_DGRAM]");
- return -1;
- }
-
- /* start listening for EAPOL on the default AP interface */
- add_ifidx(drv, if_nametoindex(drv->iface));
-
- if (hostapd_set_iface_flags(drv, drv->iface, 0))
- return -1;
-
- if (bssid) {
- os_strlcpy(ifr.ifr_name, drv->iface, IFNAMSIZ);
- memcpy(ifr.ifr_hwaddr.sa_data, bssid, ETH_ALEN);
- ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
-
- if (ioctl(drv->ioctl_sock, SIOCSIFHWADDR, &ifr)) {
- perror("ioctl(SIOCSIFHWADDR)");
- return -1;
- }
- }
-
- /*
- * initialise generic netlink and nl80211
- */
- drv->nl_cb = nl_cb_alloc(NL_CB_DEFAULT);
- if (!drv->nl_cb) {
- printf("Failed to allocate netlink callbacks.\n");
- return -1;
- }
-
- drv->nl_handle = nl_handle_alloc_cb(drv->nl_cb);
- if (!drv->nl_handle) {
- printf("Failed to allocate netlink handle.\n");
- return -1;
- }
-
- if (genl_connect(drv->nl_handle)) {
- printf("Failed to connect to generic netlink.\n");
- return -1;
- }
-
-#ifdef CONFIG_LIBNL20
- if (genl_ctrl_alloc_cache(drv->nl_handle, &drv->nl_cache) < 0) {
- printf("Failed to allocate generic netlink cache.\n");
- return -1;
- }
-#else /* CONFIG_LIBNL20 */
- drv->nl_cache = genl_ctrl_alloc_cache(drv->nl_handle);
- if (!drv->nl_cache) {
- printf("Failed to allocate generic netlink cache.\n");
- return -1;
- }
-#endif /* CONFIG_LIBNL20 */
-
- drv->nl80211 = genl_ctrl_search_by_name(drv->nl_cache, "nl80211");
- if (!drv->nl80211) {
- printf("nl80211 not found.\n");
- return -1;
- }
-
- /* Initialise a monitor interface */
- if (nl80211_create_monitor_interface(drv))
- return -1;
-
- if (nl80211_set_master_mode(drv, drv->iface))
- goto fail1;
-
- if (hostapd_set_iface_flags(drv, drv->iface, 1))
- goto fail1;
-
- memset(&addr, 0, sizeof(addr));
- addr.sll_family = AF_PACKET;
- addr.sll_ifindex = ifr.ifr_ifindex;
- wpa_printf(MSG_DEBUG, "Opening raw packet socket for ifindex %d",
- addr.sll_ifindex);
-
- drv->eapol_sock = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_PAE));
- if (drv->eapol_sock < 0) {
- perror("socket(PF_PACKET, SOCK_DGRAM, ETH_P_PAE)");
- goto fail1;
- }
-
- if (eloop_register_read_sock(drv->eapol_sock, handle_eapol, drv, NULL))
- {
- printf("Could not register read socket for eapol\n");
- return -1;
- }
-
- memset(&ifr, 0, sizeof(ifr));
- os_strlcpy(ifr.ifr_name, drv->iface, sizeof(ifr.ifr_name));
- if (ioctl(drv->ioctl_sock, SIOCGIFHWADDR, &ifr) != 0) {
- perror("ioctl(SIOCGIFHWADDR)");
- goto fail1;
- }
-
- if (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) {
- printf("Invalid HW-addr family 0x%04x\n",
- ifr.ifr_hwaddr.sa_family);
- goto fail1;
- }
- memcpy(drv->hapd->own_addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
-
- return 0;
-
-fail1:
- nl80211_remove_iface(drv, drv->monitor_ifidx);
- return -1;
-}
-
-
-static int i802_get_inact_sec(void *priv, const u8 *addr)
-{
- struct hostap_sta_driver_data data;
- int ret;
-
- data.inactive_msec = (unsigned long) -1;
- ret = i802_read_sta_data(priv, &data, addr);
- if (ret || data.inactive_msec == (unsigned long) -1)
- return -1;
- return data.inactive_msec / 1000;
-}
-
-
-static int i802_sta_clear_stats(void *priv, const u8 *addr)
-{
-#if 0
- /* TODO */
-#endif
- return 0;
-}
-
-
-static void
-hostapd_wireless_event_wireless_custom(struct i802_driver_data *drv,
- char *custom)
-{
- wpa_printf(MSG_DEBUG, "Custom wireless event: '%s'", custom);
-
- if (strncmp(custom, "MLME-MICHAELMICFAILURE.indication", 33) == 0) {
- char *pos;
- u8 addr[ETH_ALEN];
- pos = strstr(custom, "addr=");
- if (pos == NULL) {
- wpa_printf(MSG_DEBUG,
- "MLME-MICHAELMICFAILURE.indication "
- "without sender address ignored");
- return;
- }
- pos += 5;
- if (hwaddr_aton(pos, addr) == 0) {
- ieee80211_michael_mic_failure(drv->hapd, addr, 1);
- } else {
- wpa_printf(MSG_DEBUG,
- "MLME-MICHAELMICFAILURE.indication "
- "with invalid MAC address");
- }
- }
-}
-
-
-static void hostapd_wireless_event_wireless(struct i802_driver_data *drv,
- char *data, int len)
-{
- struct iw_event iwe_buf, *iwe = &iwe_buf;
- char *pos, *end, *custom, *buf;
-
- pos = data;
- end = data + len;
-
- while (pos + IW_EV_LCP_LEN <= end) {
- /* Event data may be unaligned, so make a local, aligned copy
- * before processing. */
- memcpy(&iwe_buf, pos, IW_EV_LCP_LEN);
- wpa_printf(MSG_DEBUG, "Wireless event: cmd=0x%x len=%d",
- iwe->cmd, iwe->len);
- if (iwe->len <= IW_EV_LCP_LEN)
- return;
-
- custom = pos + IW_EV_POINT_LEN;
- if (drv->we_version > 18 &&
- (iwe->cmd == IWEVMICHAELMICFAILURE ||
- iwe->cmd == IWEVCUSTOM)) {
- /* WE-19 removed the pointer from struct iw_point */
- char *dpos = (char *) &iwe_buf.u.data.length;
- int dlen = dpos - (char *) &iwe_buf;
- memcpy(dpos, pos + IW_EV_LCP_LEN,
- sizeof(struct iw_event) - dlen);
- } else {
- memcpy(&iwe_buf, pos, sizeof(struct iw_event));
- custom += IW_EV_POINT_OFF;
- }
-
- switch (iwe->cmd) {
- case IWEVCUSTOM:
- if (custom + iwe->u.data.length > end)
- return;
- buf = malloc(iwe->u.data.length + 1);
- if (buf == NULL)
- return;
- memcpy(buf, custom, iwe->u.data.length);
- buf[iwe->u.data.length] = '\0';
- hostapd_wireless_event_wireless_custom(drv, buf);
- free(buf);
- break;
- }
-
- pos += iwe->len;
- }
-}
-
-
-static void hostapd_wireless_event_rtm_newlink(struct i802_driver_data *drv,
- struct nlmsghdr *h, int len)
-{
- struct ifinfomsg *ifi;
- int attrlen, _nlmsg_len, rta_len;
- struct rtattr *attr;
-
- if (len < (int) sizeof(*ifi))
- return;
-
- ifi = NLMSG_DATA(h);
-
- /* TODO: use ifi->ifi_index to filter out wireless events from other
- * interfaces */
-
- _nlmsg_len = NLMSG_ALIGN(sizeof(struct ifinfomsg));
-
- attrlen = h->nlmsg_len - _nlmsg_len;
- if (attrlen < 0)
- return;
-
- attr = (struct rtattr *) (((char *) ifi) + _nlmsg_len);
-
- rta_len = RTA_ALIGN(sizeof(struct rtattr));
- while (RTA_OK(attr, attrlen)) {
- if (attr->rta_type == IFLA_WIRELESS) {
- hostapd_wireless_event_wireless(
- drv, ((char *) attr) + rta_len,
- attr->rta_len - rta_len);
- }
- attr = RTA_NEXT(attr, attrlen);
- }
-}
-
-
-static void hostapd_wireless_event_receive(int sock, void *eloop_ctx,
- void *sock_ctx)
-{
- char buf[256];
- int left;
- struct sockaddr_nl from;
- socklen_t fromlen;
- struct nlmsghdr *h;
- struct i802_driver_data *drv = eloop_ctx;
-
- fromlen = sizeof(from);
- left = recvfrom(sock, buf, sizeof(buf), MSG_DONTWAIT,
- (struct sockaddr *) &from, &fromlen);
- if (left < 0) {
- if (errno != EINTR && errno != EAGAIN)
- perror("recvfrom(netlink)");
- return;
- }
-
- h = (struct nlmsghdr *) buf;
- while (left >= (int) sizeof(*h)) {
- int len, plen;
-
- len = h->nlmsg_len;
- plen = len - sizeof(*h);
- if (len > left || plen < 0) {
- printf("Malformed netlink message: "
- "len=%d left=%d plen=%d\n",
- len, left, plen);
- break;
- }
-
- switch (h->nlmsg_type) {
- case RTM_NEWLINK:
- hostapd_wireless_event_rtm_newlink(drv, h, plen);
- break;
- }
-
- len = NLMSG_ALIGN(len);
- left -= len;
- h = (struct nlmsghdr *) ((char *) h + len);
- }
-
- if (left > 0) {
- printf("%d extra bytes in the end of netlink message\n", left);
- }
-}
-
-
-static int hostap_get_we_version(struct i802_driver_data *drv)
-{
- struct iw_range *range;
- struct iwreq iwr;
- int minlen;
- size_t buflen;
-
- drv->we_version = 0;
-
- /*
- * Use larger buffer than struct iw_range in order to allow the
- * structure to grow in the future.
- */
- buflen = sizeof(struct iw_range) + 500;
- range = os_zalloc(buflen);
- if (range == NULL)
- return -1;
-
- memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
- iwr.u.data.pointer = (caddr_t) range;
- iwr.u.data.length = buflen;
-
- minlen = ((char *) &range->enc_capa) - (char *) range +
- sizeof(range->enc_capa);
-
- if (ioctl(drv->ioctl_sock, SIOCGIWRANGE, &iwr) < 0) {
- perror("ioctl[SIOCGIWRANGE]");
- free(range);
- return -1;
- } else if (iwr.u.data.length >= minlen &&
- range->we_version_compiled >= 18) {
- wpa_printf(MSG_DEBUG, "SIOCGIWRANGE: WE(compiled)=%d "
- "WE(source)=%d enc_capa=0x%x",
- range->we_version_compiled,
- range->we_version_source,
- range->enc_capa);
- drv->we_version = range->we_version_compiled;
- }
-
- free(range);
- return 0;
-}
-
-
-static int i802_wireless_event_init(void *priv)
-{
- struct i802_driver_data *drv = priv;
- int s;
- struct sockaddr_nl local;
-
- hostap_get_we_version(drv);
-
- drv->wext_sock = -1;
-
- s = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
- if (s < 0) {
- perror("socket(PF_NETLINK,SOCK_RAW,NETLINK_ROUTE)");
- return -1;
- }
-
- memset(&local, 0, sizeof(local));
- local.nl_family = AF_NETLINK;
- local.nl_groups = RTMGRP_LINK;
- if (bind(s, (struct sockaddr *) &local, sizeof(local)) < 0) {
- perror("bind(netlink)");
- close(s);
- return -1;
- }
-
- eloop_register_read_sock(s, hostapd_wireless_event_receive, drv,
- NULL);
- drv->wext_sock = s;
-
- return 0;
-}
-
-
-static void i802_wireless_event_deinit(void *priv)
-{
- struct i802_driver_data *drv = priv;
- if (drv->wext_sock < 0)
- return;
- eloop_unregister_read_sock(drv->wext_sock);
- close(drv->wext_sock);
-}
-
-
-static int i802_sta_deauth(void *priv, const u8 *addr, int reason)
-{
- struct i802_driver_data *drv = priv;
- struct ieee80211_mgmt mgmt;
-
- memset(&mgmt, 0, sizeof(mgmt));
- mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
- WLAN_FC_STYPE_DEAUTH);
- memcpy(mgmt.da, addr, ETH_ALEN);
- memcpy(mgmt.sa, drv->hapd->own_addr, ETH_ALEN);
- memcpy(mgmt.bssid, drv->hapd->own_addr, ETH_ALEN);
- mgmt.u.deauth.reason_code = host_to_le16(reason);
- return i802_send_mgmt_frame(drv, &mgmt, IEEE80211_HDRLEN +
- sizeof(mgmt.u.deauth), 0);
-}
-
-
-static int i802_sta_disassoc(void *priv, const u8 *addr, int reason)
-{
- struct i802_driver_data *drv = priv;
- struct ieee80211_mgmt mgmt;
-
- memset(&mgmt, 0, sizeof(mgmt));
- mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
- WLAN_FC_STYPE_DISASSOC);
- memcpy(mgmt.da, addr, ETH_ALEN);
- memcpy(mgmt.sa, drv->hapd->own_addr, ETH_ALEN);
- memcpy(mgmt.bssid, drv->hapd->own_addr, ETH_ALEN);
- mgmt.u.disassoc.reason_code = host_to_le16(reason);
- return i802_send_mgmt_frame(drv, &mgmt, IEEE80211_HDRLEN +
- sizeof(mgmt.u.disassoc), 0);
-}
-
-
-static void *i802_init_bssid(struct hostapd_data *hapd, const u8 *bssid)
-{
- struct i802_driver_data *drv;
-
- drv = os_zalloc(sizeof(struct i802_driver_data));
- if (drv == NULL) {
- printf("Could not allocate memory for i802 driver data\n");
- return NULL;
- }
-
- drv->hapd = hapd;
- memcpy(drv->iface, hapd->conf->iface, sizeof(drv->iface));
-
- drv->num_if_indices = sizeof(drv->default_if_indices) / sizeof(int);
- drv->if_indices = drv->default_if_indices;
- drv->bridge = if_nametoindex(hapd->conf->bridge);
-
- if (i802_init_sockets(drv, bssid))
- goto failed;
-
- return drv;
-
-failed:
- free(drv);
- return NULL;
-}
-
-
-static void *i802_init(struct hostapd_data *hapd)
-{
- return i802_init_bssid(hapd, NULL);
-}
-
-
-static void i802_deinit(void *priv)
-{
- struct i802_driver_data *drv = priv;
-
- if (drv->last_freq_ht) {
- /* Clear HT flags from the driver */
- struct hostapd_freq_params freq;
- os_memset(&freq, 0, sizeof(freq));
- freq.freq = drv->last_freq;
- i802_set_freq2(priv, &freq);
- }
-
- i802_del_beacon(drv);
-
- /* remove monitor interface */
- nl80211_remove_iface(drv, drv->monitor_ifidx);
-
- (void) hostapd_set_iface_flags(drv, drv->iface, 0);
-
- if (drv->monitor_sock >= 0) {
- eloop_unregister_read_sock(drv->monitor_sock);
- close(drv->monitor_sock);
- }
- if (drv->ioctl_sock >= 0)
- close(drv->ioctl_sock);
- if (drv->eapol_sock >= 0) {
- eloop_unregister_read_sock(drv->eapol_sock);
- close(drv->eapol_sock);
- }
-
- genl_family_put(drv->nl80211);
- nl_cache_free(drv->nl_cache);
- nl_handle_destroy(drv->nl_handle);
- nl_cb_put(drv->nl_cb);
-
- if (drv->if_indices != drv->default_if_indices)
- free(drv->if_indices);
-
- free(drv);
-}
-
-
-const struct wpa_driver_ops wpa_driver_nl80211_ops = {
- .name = "nl80211",
- .init = i802_init,
- .init_bssid = i802_init_bssid,
- .deinit = i802_deinit,
- .wireless_event_init = i802_wireless_event_init,
- .wireless_event_deinit = i802_wireless_event_deinit,
- .set_ieee8021x = i802_set_ieee8021x,
- .set_privacy = i802_set_privacy,
- .set_encryption = i802_set_encryption,
- .get_seqnum = i802_get_seqnum,
- .flush = i802_flush,
- .read_sta_data = i802_read_sta_data,
- .send_eapol = i802_send_eapol,
- .sta_set_flags = i802_sta_set_flags,
- .sta_deauth = i802_sta_deauth,
- .sta_disassoc = i802_sta_disassoc,
- .sta_remove = i802_sta_remove,
- .send_mgmt_frame = i802_send_mgmt_frame,
- .sta_add2 = i802_sta_add2,
- .get_inact_sec = i802_get_inact_sec,
- .sta_clear_stats = i802_sta_clear_stats,
- .set_freq2 = i802_set_freq2,
- .set_rts = i802_set_rts,
- .get_rts = i802_get_rts,
- .set_frag = i802_set_frag,
- .get_frag = i802_get_frag,
- .set_retry = i802_set_retry,
- .get_retry = i802_get_retry,
- .set_rate_sets = i802_set_rate_sets,
- .set_regulatory_domain = i802_set_regulatory_domain,
- .set_beacon = i802_set_beacon,
- .set_internal_bridge = i802_set_internal_bridge,
- .set_beacon_int = i802_set_beacon_int,
- .set_dtim_period = i802_set_dtim_period,
- .set_cts_protect = i802_set_cts_protect,
- .set_preamble = i802_set_preamble,
- .set_short_slot_time = i802_set_short_slot_time,
- .set_tx_queue_params = i802_set_tx_queue_params,
- .bss_add = i802_bss_add,
- .bss_remove = i802_bss_remove,
- .if_add = i802_if_add,
- .if_update = i802_if_update,
- .if_remove = i802_if_remove,
- .get_hw_feature_data = i802_get_hw_feature_data,
- .set_sta_vlan = i802_set_sta_vlan,
- .set_country = i802_set_country,
-};
diff --git a/hostapd/driver_prism54.c b/hostapd/driver_prism54.c
deleted file mode 100644
index 4e2189aeb5f6..000000000000
--- a/hostapd/driver_prism54.c
+++ /dev/null
@@ -1,1091 +0,0 @@
-/*
- * hostapd / Driver interaction with Prism54 PIMFOR interface
- * Copyright (c) 2004, Bell Kin <bell_kin@pek.com.tw>
- * based on hostap driver.c, ieee802_11.c
- * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Alternatively, this software may be distributed under the terms of BSD
- * license.
- *
- * See README and COPYING for more details.
- */
-
-#include "includes.h"
-#include <sys/ioctl.h>
-#include <sys/select.h>
-
-#ifdef USE_KERNEL_HEADERS
-/* compat-wireless does not include linux/compiler.h to define __user, so
- * define it here */
-#ifndef __user
-#define __user
-#endif /* __user */
-#include <asm/types.h>
-#include <linux/if_packet.h>
-#include <linux/if_ether.h> /* The L2 protocols */
-#include <linux/if_arp.h>
-#include <linux/wireless.h>
-#else /* USE_KERNEL_HEADERS */
-#include <net/if_arp.h>
-#include <netpacket/packet.h>
-#include "wireless_copy.h"
-#endif /* USE_KERNEL_HEADERS */
-
-#include "hostapd.h"
-#include "driver.h"
-#include "ieee802_1x.h"
-#include "eloop.h"
-#include "ieee802_11.h"
-#include "prism54.h"
-#include "wpa.h"
-#include "radius/radius.h"
-#include "sta_info.h"
-#include "accounting.h"
-
-const int PIM_BUF_SIZE = 4096;
-
-struct prism54_driver_data {
- struct hostapd_data *hapd;
- char iface[IFNAMSIZ + 1];
- int sock; /* raw packet socket for 802.3 access */
- int pim_sock; /* socket for pimfor packet */
- char macs[2007][6];
-};
-
-
-static int mac_id_refresh(struct prism54_driver_data *data, int id, char *mac)
-{
- if (id < 0 || id > 2006) {
- return -1;
- }
- memcpy(&data->macs[id][0], mac, ETH_ALEN);
- return 0;
-}
-
-
-static char * mac_id_get(struct prism54_driver_data *data, int id)
-{
- if (id < 0 || id > 2006) {
- return NULL;
- }
- return &data->macs[id][0];
-}
-
-
-/* wait for a specific pimfor, timeout in 10ms resolution */
-/* pim_sock must be non-block to prevent dead lock from no response */
-/* or same response type in series */
-static int prism54_waitpim(void *priv, unsigned long oid, void *buf, int len,
- int timeout)
-{
- struct prism54_driver_data *drv = priv;
- struct timeval tv, stv, ctv;
- fd_set pfd;
- int rlen;
- pimdev_hdr *pkt;
-
- pkt = malloc(8192);
- if (pkt == NULL)
- return -1;
-
- FD_ZERO(&pfd);
- gettimeofday(&stv, NULL);
- do {
- FD_SET(drv->pim_sock, &pfd);
- tv.tv_sec = 0;
- tv.tv_usec = 10000;
- if (select(drv->pim_sock + 1, &pfd, NULL, NULL, &tv)) {
- rlen = recv(drv->pim_sock, pkt, 8192, 0);
- if (rlen > 0) {
- if (pkt->oid == htonl(oid)) {
- if (rlen <= len) {
- if (buf != NULL) {
- memcpy(buf, pkt, rlen);
- }
- free(pkt);
- return rlen;
- } else {
- printf("buffer too small\n");
- free(pkt);
- return -1;
- }
- } else {
- gettimeofday(&ctv, NULL);
- continue;
- }
- }
- }
- gettimeofday(&ctv, NULL);
- } while (((ctv.tv_sec - stv.tv_sec) * 100 +
- (ctv.tv_usec - stv.tv_usec) / 10000) > timeout);
- free(pkt);
- return 0;
-}
-
-
-/* send an eapol packet */
-static int prism54_send_eapol(void *priv, const u8 *addr,
- const u8 *data, size_t data_len, int encrypt,
- const u8 *own_addr)
-{
- struct prism54_driver_data *drv = priv;
- ieee802_3_hdr *hdr;
- size_t len;
- u8 *pos;
- int res;
-
- len = sizeof(*hdr) + data_len;
- hdr = os_zalloc(len);
- if (hdr == NULL) {
- printf("malloc() failed for prism54_send_data(len=%lu)\n",
- (unsigned long) len);
- return -1;
- }
-
- memcpy(&hdr->da[0], addr, ETH_ALEN);
- memcpy(&hdr->sa[0], own_addr, ETH_ALEN);
- hdr->type = htons(ETH_P_PAE);
- pos = (u8 *) (hdr + 1);
- memcpy(pos, data, data_len);
-
- res = send(drv->sock, hdr, len, 0);
- free(hdr);
-
- if (res < 0) {
- perror("hostapd_send_eapol: send");
- printf("hostapd_send_eapol - packet len: %lu - failed\n",
- (unsigned long) len);
- }
-
- return res;
-}
-
-
-/* open data channel(auth-1) or eapol only(unauth-0) */
-static int prism54_set_sta_authorized(void *priv, const u8 *addr,
- int authorized)
-{
- struct prism54_driver_data *drv = priv;
- pimdev_hdr *hdr;
- char *pos;
-
- hdr = malloc(sizeof(*hdr) + ETH_ALEN);
- if (hdr == NULL)
- return -1;
- hdr->op = htonl(PIMOP_SET);
- if (authorized) {
- hdr->oid = htonl(DOT11_OID_EAPAUTHSTA);
- } else {
- hdr->oid = htonl(DOT11_OID_EAPUNAUTHSTA);
- }
- pos = (char *) (hdr + 1);
- memcpy(pos, addr, ETH_ALEN);
- send(drv->pim_sock, hdr, sizeof(*hdr) + ETH_ALEN, 0);
- prism54_waitpim(priv, hdr->oid, hdr, sizeof(*hdr) + ETH_ALEN, 10);
- free(hdr);
- return 0;
-}
-
-
-static int
-prism54_sta_set_flags(void *priv, const u8 *addr, int total_flags,
- int flags_or, int flags_and)
-{
- /* For now, only support setting Authorized flag */
- if (flags_or & WLAN_STA_AUTHORIZED)
- return prism54_set_sta_authorized(priv, addr, 1);
- if (flags_and & WLAN_STA_AUTHORIZED)
- return prism54_set_sta_authorized(priv, addr, 0);
- return 0;
-}
-
-
-/* set per station key */
-static int prism54_set_encryption(const char *ifname, void *priv,
- const char *alg, const u8 *addr,
- int idx, const u8 *key, size_t key_len,
- int txkey)
-{
- struct prism54_driver_data *drv = priv;
- pimdev_hdr *hdr;
- struct obj_stakey *keys;
- u8 *buf;
- size_t blen;
- int ret = 0;
-
- blen = sizeof(struct obj_stakey) + sizeof(pimdev_hdr);
- hdr = malloc(blen);
- if (hdr == NULL) {
- printf("memory low\n");
- return -1;
- }
- keys = (struct obj_stakey *) &hdr[1];
- if (!addr) {
- memset(&keys->address[0], 0xff, ETH_ALEN);
- } else {
- memcpy(&keys->address[0], addr, ETH_ALEN);
- }
- if (!strcmp(alg, "WEP")) {
- keys->type = DOT11_PRIV_WEP;
- } else if (!strcmp(alg, "TKIP")) {
- keys->type = DOT11_PRIV_TKIP;
- } else if (!strcmp(alg, "none")) {
- /* the only way to clear the key is to deauth it */
- /* and prism54 is capable to receive unencrypted packet */
- /* so we do nothing here */
- free(hdr);
- return 0;
- } else {
- printf("bad auth type: %s\n", alg);
- }
- buf = (u8 *) &keys->key[0];
- keys->length = key_len;
- keys->keyid = idx;
- keys->options = htons(DOT11_STAKEY_OPTION_DEFAULTKEY);
- keys->reserved = 0;
-
- hdr->op = htonl(PIMOP_SET);
- hdr->oid = htonl(DOT11_OID_STAKEY);
-
- memcpy(buf, key, key_len);
-
- ret = send(drv->pim_sock, hdr, blen, 0);
- if (ret < 0) {
- free(hdr);
- return ret;
- }
- prism54_waitpim(priv, hdr->oid, hdr, blen, 10);
-
- free(hdr);
-
- return 0;
-}
-
-
-/* get TKIP station sequence counter, prism54 is only 6 bytes */
-static int prism54_get_seqnum(const char *ifname, void *priv, const u8 *addr,
- int idx, u8 *seq)
-{
- struct prism54_driver_data *drv = priv;
- struct obj_stasc *stasc;
- pimdev_hdr *hdr;
- size_t blen;
- int ret = 0;
-
- blen = sizeof(*stasc) + sizeof(*hdr);
- hdr = malloc(blen);
- if (hdr == NULL)
- return -1;
-
- stasc = (struct obj_stasc *) &hdr[1];
-
- if (addr == NULL)
- memset(&stasc->address[0], 0xff, ETH_ALEN);
- else
- memcpy(&stasc->address[0], addr, ETH_ALEN);
-
- hdr->oid = htonl(DOT11_OID_STASC);
- hdr->op = htonl(PIMOP_GET);
- stasc->keyid = idx;
- if (send(drv->pim_sock,hdr,blen,0) <= 0) {
- free(hdr);
- return -1;
- }
- if (prism54_waitpim(priv, DOT11_OID_STASC, hdr, blen, 10) <= 0) {
- ret = -1;
- } else {
- if (hdr->op == (int) htonl(PIMOP_RESPONSE)) {
- memcpy(seq + 2, &stasc->sc_high, ETH_ALEN);
- memset(seq, 0, 2);
- } else {
- ret = -1;
- }
- }
- free(hdr);
-
- return ret;
-}
-
-
-/* include unencrypted, set mlme autolevel to extended */
-static int prism54_init_1x(void *priv)
-{
- struct prism54_driver_data *drv = priv;
- pimdev_hdr *hdr;
- unsigned long *ul;
- int blen = sizeof(*hdr) + sizeof(*ul);
-
- hdr = malloc(blen);
- if (hdr == NULL)
- return -1;
-
- ul = (unsigned long *) &hdr[1];
- hdr->op = htonl(PIMOP_SET);
- hdr->oid = htonl(DOT11_OID_EXUNENCRYPTED);
- *ul = htonl(DOT11_BOOL_TRUE); /* not accept */
- send(drv->pim_sock, hdr, blen, 0);
- prism54_waitpim(priv, DOT11_OID_EXUNENCRYPTED, hdr, blen, 10);
- hdr->op = htonl(PIMOP_SET);
- hdr->oid = htonl(DOT11_OID_MLMEAUTOLEVEL);
- *ul = htonl(DOT11_MLME_EXTENDED);
- send(drv->pim_sock, hdr, blen, 0);
- prism54_waitpim(priv, DOT11_OID_MLMEAUTOLEVEL, hdr, blen, 10);
- hdr->op = htonl(PIMOP_SET);
- hdr->oid = htonl(DOT11_OID_DOT1XENABLE);
- *ul = htonl(DOT11_BOOL_TRUE);
- send(drv->pim_sock, hdr, blen, 0);
- prism54_waitpim(priv, DOT11_OID_DOT1XENABLE, hdr, blen, 10);
- hdr->op = htonl(PIMOP_SET);
- hdr->oid = htonl(DOT11_OID_AUTHENABLE);
- *ul = htonl(DOT11_AUTH_OS); /* OS */
- send(drv->pim_sock, hdr, blen, 0);
- prism54_waitpim(priv, DOT11_OID_AUTHENABLE, hdr, blen, 10);
- free(hdr);
- return 0;
-}
-
-
-static int prism54_set_privacy_invoked(const char *ifname, void *priv,
- int flag)
-{
- struct prism54_driver_data *drv = priv;
- pimdev_hdr *hdr;
- unsigned long *ul;
- int ret;
- int blen = sizeof(*hdr) + sizeof(*ul);
- hdr = malloc(blen);
- if (hdr == NULL)
- return -1;
- ul = (unsigned long *) &hdr[1];
- hdr->op = htonl(PIMOP_SET);
- hdr->oid = htonl(DOT11_OID_PRIVACYINVOKED);
- if (flag) {
- *ul = htonl(DOT11_BOOL_TRUE); /* has privacy */
- } else {
- *ul = 0;
- }
- ret = send(drv->pim_sock, hdr, blen, 0);
- if (ret >= 0) {
- ret = prism54_waitpim(priv, DOT11_OID_PRIVACYINVOKED, hdr,
- blen, 10);
- }
- free(hdr);
- return ret;
-}
-
-
-static int prism54_ioctl_setiwessid(const char *ifname, void *priv,
- const u8 *buf, int len)
-{
-#if 0
- struct prism54_driver_data *drv = priv;
- struct iwreq iwr;
-
- memset(&iwr, 0, sizeof(iwr));
- os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
- iwr.u.essid.flags = 1; /* SSID active */
- iwr.u.essid.pointer = (caddr_t) buf;
- iwr.u.essid.length = len + 1;
-
- if (ioctl(drv->pim_sock, SIOCSIWESSID, &iwr) < 0) {
- perror("ioctl[SIOCSIWESSID]");
- printf("len=%d\n", len);
- return -1;
- }
-#endif
- return 0;
-}
-
-
-/* kick all stations */
-/* does not work during init, but at least it won't crash firmware */
-static int prism54_flush(void *priv)
-{
- struct prism54_driver_data *drv = priv;
- struct obj_mlmeex *mlme;
- pimdev_hdr *hdr;
- int ret;
- unsigned int i;
- long *nsta;
- int blen = sizeof(*hdr) + sizeof(*mlme);
- char *mac_id;
-
- hdr = os_zalloc(blen);
- if (hdr == NULL)
- return -1;
-
- mlme = (struct obj_mlmeex *) &hdr[1];
- nsta = (long *) &hdr[1];
- hdr->op = htonl(PIMOP_GET);
- hdr->oid = htonl(DOT11_OID_CLIENTS);
- ret = send(drv->pim_sock, hdr, sizeof(*hdr) + sizeof(long), 0);
- ret = prism54_waitpim(priv, DOT11_OID_CLIENTS, hdr, blen, 10);
- if ((ret < 0) || (hdr->op != (int) htonl(PIMOP_RESPONSE)) ||
- (le_to_host32(*nsta) > 2007)) {
- free(hdr);
- return 0;
- }
- for (i = 0; i < le_to_host32(*nsta); i++) {
- mlme->id = -1;
- mac_id = mac_id_get(drv, i);
- if (mac_id)
- memcpy(&mlme->address[0], mac_id, ETH_ALEN);
- mlme->code = host_to_le16(WLAN_REASON_UNSPECIFIED);
- mlme->state = htons(DOT11_STATE_NONE);
- mlme->size = 0;
- hdr->op = htonl(PIMOP_SET);
- hdr->oid = htonl(DOT11_OID_DISASSOCIATEEX);
- ret = send(drv->pim_sock, hdr, blen, 0);
- prism54_waitpim(priv, DOT11_OID_DISASSOCIATEEX, hdr, blen,
- 100);
- }
- for (i = 0; i < le_to_host32(*nsta); i++) {
- mlme->id = -1;
- mac_id = mac_id_get(drv, i);
- if (mac_id)
- memcpy(&mlme->address[0], mac_id, ETH_ALEN);
- mlme->code = host_to_le16(WLAN_REASON_UNSPECIFIED);
- mlme->state = htons(DOT11_STATE_NONE);
- mlme->size = 0;
- hdr->op = htonl(PIMOP_SET);
- hdr->oid = htonl(DOT11_OID_DEAUTHENTICATEEX);
- ret = send(drv->pim_sock, hdr, blen, 0);
- prism54_waitpim(priv, DOT11_OID_DEAUTHENTICATEEX, hdr, blen,
- 100);
- }
- free(hdr);
- return 0;
-}
-
-
-static int prism54_sta_deauth(void *priv, const u8 *addr, int reason)
-{
- struct prism54_driver_data *drv = priv;
- pimdev_hdr *hdr;
- struct obj_mlmeex *mlme;
- int ret;
- int blen = sizeof(*hdr) + sizeof(*mlme);
- hdr = malloc(blen);
- if (hdr == NULL)
- return -1;
- mlme = (struct obj_mlmeex *) &hdr[1];
- hdr->op = htonl(PIMOP_SET);
- hdr->oid = htonl(DOT11_OID_DEAUTHENTICATEEX);
- memcpy(&mlme->address[0], addr, ETH_ALEN);
- mlme->id = -1;
- mlme->state = htons(DOT11_STATE_NONE);
- mlme->code = host_to_le16(reason);
- mlme->size = 0;
- ret = send(drv->pim_sock, hdr, blen, 0);
- prism54_waitpim(priv, DOT11_OID_DEAUTHENTICATEEX, hdr, blen, 10);
- free(hdr);
- return ret;
-}
-
-
-static int prism54_sta_disassoc(void *priv, const u8 *addr, int reason)
-{
- struct prism54_driver_data *drv = priv;
- pimdev_hdr *hdr;
- struct obj_mlmeex *mlme;
- int ret;
- int blen = sizeof(*hdr) + sizeof(*mlme);
- hdr = malloc(blen);
- if (hdr == NULL)
- return -1;
- mlme = (struct obj_mlmeex *) &hdr[1];
- hdr->op = htonl(PIMOP_SET);
- hdr->oid = htonl(DOT11_OID_DISASSOCIATEEX);
- memcpy(&mlme->address[0], addr, ETH_ALEN);
- mlme->id = -1;
- mlme->state = htons(DOT11_STATE_NONE);
- mlme->code = host_to_le16(reason);
- mlme->size = 0;
- ret = send(drv->pim_sock, hdr, blen, 0);
- prism54_waitpim(priv, DOT11_OID_DISASSOCIATEEX, hdr, blen, 10);
- free(hdr);
- return ret;
-}
-
-
-static int prism54_get_inact_sec(void *priv, const u8 *addr)
-{
- struct prism54_driver_data *drv = priv;
- pimdev_hdr *hdr;
- struct obj_sta *sta;
- int blen = sizeof(*hdr) + sizeof(*sta);
- int ret;
-
- hdr = malloc(blen);
- if (hdr == NULL)
- return -1;
- hdr->op = htonl(PIMOP_GET);
- hdr->oid = htonl(DOT11_OID_CLIENTFIND);
- sta = (struct obj_sta *) &hdr[1];
- memcpy(&sta->address[0], addr, ETH_ALEN);
- ret = send(drv->pim_sock, hdr, blen, 0);
- ret = prism54_waitpim(priv, DOT11_OID_CLIENTFIND, hdr, blen, 10);
- if (ret != blen) {
- printf("get_inact_sec: bad return %d\n", ret);
- free(hdr);
- return -1;
- }
- if (hdr->op != (int) htonl(PIMOP_RESPONSE)) {
- printf("get_inact_sec: bad resp\n");
- free(hdr);
- return -1;
- }
- free(hdr);
- return le_to_host16(sta->age);
-}
-
-
-/* set attachments */
-static int prism54_set_generic_elem(const char *ifname, void *priv,
- const u8 *elem, size_t elem_len)
-{
- struct prism54_driver_data *drv = priv;
- pimdev_hdr *hdr;
- char *pos;
- struct obj_attachment_hdr *attach;
- size_t blen = sizeof(*hdr) + sizeof(*attach) + elem_len;
- hdr = os_zalloc(blen);
- if (hdr == NULL) {
- printf("%s: memory low\n", __func__);
- return -1;
- }
- hdr->op = htonl(PIMOP_SET);
- hdr->oid = htonl(DOT11_OID_ATTACHMENT);
- attach = (struct obj_attachment_hdr *)&hdr[1];
- attach->type = DOT11_PKT_BEACON;
- attach->id = -1;
- attach->size = host_to_le16((short)elem_len);
- pos = ((char*) attach) + sizeof(*attach);
- if (elem)
- memcpy(pos, elem, elem_len);
- send(drv->pim_sock, hdr, blen, 0);
- attach->type = DOT11_PKT_PROBE_RESP;
- send(drv->pim_sock, hdr, blen, 0);
- free(hdr);
- return 0;
-}
-
-
-/* tell the card to auth the sta */
-static void prism54_handle_probe(struct prism54_driver_data *drv,
- void *buf, size_t len)
-{
- struct obj_mlmeex *mlme;
- pimdev_hdr *hdr;
- struct sta_info *sta;
- hdr = (pimdev_hdr *)buf;
- mlme = (struct obj_mlmeex *) &hdr[1];
- sta = ap_get_sta(drv->hapd, (u8 *) &mlme->address[0]);
- if (sta != NULL) {
- if (sta->flags & (WLAN_STA_AUTH | WLAN_STA_ASSOC))
- return;
- }
- if (len < sizeof(*mlme)) {
- printf("bad probe packet\n");
- return;
- }
- mlme->state = htons(DOT11_STATE_AUTHING);
- mlme->code = 0;
- hdr->op = htonl(PIMOP_SET);
- hdr->oid = htonl(DOT11_OID_AUTHENTICATEEX);
- mlme->size = 0;
- send(drv->pim_sock, hdr, sizeof(*hdr)+sizeof(*mlme), 0);
-}
-
-
-static void prism54_handle_deauth(struct prism54_driver_data *drv,
- void *buf, size_t len)
-{
- struct obj_mlme *mlme;
- pimdev_hdr *hdr;
- struct sta_info *sta;
- char *mac_id;
-
- hdr = (pimdev_hdr *) buf;
- mlme = (struct obj_mlme *) &hdr[1];
- sta = ap_get_sta(drv->hapd, (u8 *) &mlme->address[0]);
- mac_id = mac_id_get(drv, mlme->id);
- if (sta == NULL || mac_id == NULL)
- return;
- memcpy(&mlme->address[0], mac_id, ETH_ALEN);
- sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
- wpa_auth_sm_event(sta->wpa_sm, WPA_DEAUTH);
- sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
- ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
- ap_free_sta(drv->hapd, sta);
-}
-
-
-static void prism54_handle_disassoc(struct prism54_driver_data *drv,
- void *buf, size_t len)
-{
- struct obj_mlme *mlme;
- pimdev_hdr *hdr;
- struct sta_info *sta;
- char *mac_id;
-
- hdr = (pimdev_hdr *) buf;
- mlme = (struct obj_mlme *) &hdr[1];
- mac_id = mac_id_get(drv, mlme->id);
- if (mac_id == NULL)
- return;
- memcpy(&mlme->address[0], mac_id, ETH_ALEN);
- sta = ap_get_sta(drv->hapd, (u8 *) &mlme->address[0]);
- if (sta == NULL) {
- return;
- }
- sta->flags &= ~WLAN_STA_ASSOC;
- wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC);
- sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
- ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
- accounting_sta_stop(drv->hapd, sta);
- ieee802_1x_free_station(sta);
-}
-
-
-/* to auth it, just allow it now, later for os/sk */
-static void prism54_handle_auth(struct prism54_driver_data *drv,
- void *buf, size_t len)
-{
- struct obj_mlmeex *mlme;
- pimdev_hdr *hdr;
- struct sta_info *sta;
- int resp;
-
- hdr = (pimdev_hdr *) buf;
- mlme = (struct obj_mlmeex *) &hdr[1];
- if (len < sizeof(*mlme)) {
- printf("bad auth packet\n");
- return;
- }
-
- if (mlme->state == htons(DOT11_STATE_AUTHING)) {
- sta = ap_sta_add(drv->hapd, (u8 *) &mlme->address[0]);
- if (drv->hapd->tkip_countermeasures) {
- resp = WLAN_REASON_MICHAEL_MIC_FAILURE;
- goto fail;
- }
- mac_id_refresh(drv, mlme->id, &mlme->address[0]);
- if (!sta) {
- resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
- goto fail;
- }
- sta->flags &= ~WLAN_STA_PREAUTH;
-
- ieee802_1x_notify_pre_auth(sta->eapol_sm, 0);
- sta->flags |= WLAN_STA_AUTH;
- wpa_auth_sm_event(sta->wpa_sm, WPA_AUTH);
- mlme->code = 0;
- mlme->state=htons(DOT11_STATE_AUTH);
- hdr->op = htonl(PIMOP_SET);
- hdr->oid = htonl(DOT11_OID_AUTHENTICATEEX);
- mlme->size = 0;
- sta->timeout_next = STA_NULLFUNC;
- send(drv->pim_sock, hdr, sizeof(*hdr) + sizeof(*mlme), 0);
- }
- return;
-
-fail:
- printf("auth fail: %x\n", resp);
- mlme->code = host_to_le16(resp);
- mlme->size = 0;
- if (sta)
- sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
- hdr->oid = htonl(DOT11_OID_DEAUTHENTICATEEX);
- hdr->op = htonl(PIMOP_SET);
- send(drv->pim_sock, hdr, sizeof(*hdr)+sizeof(*mlme), 0);
-}
-
-
-/* do the wpa thing */
-static void prism54_handle_assoc(struct prism54_driver_data *drv,
- void *buf, size_t len)
-{
- pimdev_hdr *hdr;
- struct obj_mlmeex *mlme;
- struct ieee802_11_elems elems;
- struct sta_info *sta;
- u8 *wpa_ie;
- u8 *cb;
- int ieofs = 0;
- size_t wpa_ie_len;
- int resp, new_assoc;
- char *mac_id;
-
- resp = 0;
- hdr = (pimdev_hdr *) buf;
- mlme = (struct obj_mlmeex *) &hdr[1];
- switch (ntohl(hdr->oid)) {
- case DOT11_OID_ASSOCIATE:
- case DOT11_OID_REASSOCIATE:
- mlme->size = 0;
- default:
- break;
- }
- if ((mlme->state == (int) htonl(DOT11_STATE_ASSOCING)) ||
- (mlme->state == (int) htonl(DOT11_STATE_REASSOCING))) {
- if (len < sizeof(pimdev_hdr) + sizeof(struct obj_mlme)) {
- printf("bad assoc packet\n");
- return;
- }
- mac_id = mac_id_get(drv, mlme->id);
- if (mac_id == NULL)
- return;
- memcpy(&mlme->address[0], mac_id, ETH_ALEN);
- sta = ap_get_sta(drv->hapd, (u8 *) &mlme->address[0]);
- if (sta == NULL) {
- printf("cannot get sta\n");
- return;
- }
- cb = (u8 *) &mlme->data[0];
- if (hdr->oid == htonl(DOT11_OID_ASSOCIATEEX)) {
- ieofs = 4;
- } else if (hdr->oid == htonl(DOT11_OID_REASSOCIATEEX)) {
- ieofs = 10;
- }
- if (le_to_host16(mlme->size) <= ieofs) {
- printf("attach too small\n");
- resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
- goto fail;
- }
- if (ieee802_11_parse_elems(cb + ieofs,
- le_to_host16(mlme->size) - ieofs,
- &elems, 1) == ParseFailed) {
- printf("STA " MACSTR " sent invalid association "
- "request\n", MAC2STR(sta->addr));
- resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
- goto fail;
- }
- if ((drv->hapd->conf->wpa & WPA_PROTO_RSN) &&
- elems.rsn_ie) {
- wpa_ie = elems.rsn_ie;
- wpa_ie_len = elems.rsn_ie_len;
- } else if ((drv->hapd->conf->wpa & WPA_PROTO_WPA) &&
- elems.wpa_ie) {
- wpa_ie = elems.wpa_ie;
- wpa_ie_len = elems.wpa_ie_len;
- } else {
- wpa_ie = NULL;
- wpa_ie_len = 0;
- }
- if (drv->hapd->conf->wpa && wpa_ie == NULL) {
- printf("STA " MACSTR ": No WPA/RSN IE in association "
- "request\n", MAC2STR(sta->addr));
- resp = WLAN_STATUS_INVALID_IE;
- goto fail;
- }
- if (drv->hapd->conf->wpa) {
- int res;
- wpa_ie -= 2;
- wpa_ie_len += 2;
- if (sta->wpa_sm == NULL)
- sta->wpa_sm = wpa_auth_sta_init(
- drv->hapd->wpa_auth, sta->addr);
- if (sta->wpa_sm == NULL) {
- printf("Failed to initialize WPA state "
- "machine\n");
- resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
- goto fail;
- }
- res = wpa_validate_wpa_ie(drv->hapd->wpa_auth,
- sta->wpa_sm,
- wpa_ie, wpa_ie_len,
- NULL, 0);
- if (res == WPA_INVALID_GROUP)
- resp = WLAN_STATUS_GROUP_CIPHER_NOT_VALID;
- else if (res == WPA_INVALID_PAIRWISE)
- resp = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID;
- else if (res == WPA_INVALID_AKMP)
- resp = WLAN_STATUS_AKMP_NOT_VALID;
- else if (res == WPA_ALLOC_FAIL)
- resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
- else if (res != WPA_IE_OK)
- resp = WLAN_STATUS_INVALID_IE;
- if (resp != WLAN_STATUS_SUCCESS)
- goto fail;
- }
- hdr->oid = (hdr->oid == htonl(DOT11_OID_ASSOCIATEEX)) ?
- htonl(DOT11_OID_ASSOCIATEEX) :
- htonl(DOT11_OID_REASSOCIATEEX);
- hdr->op = htonl(PIMOP_SET);
- mlme->code = 0;
- mlme->state = htons(DOT11_STATE_ASSOC);
- mlme->size = 0;
- send(drv->pim_sock, hdr, sizeof(*hdr) + sizeof(*mlme), 0);
- return;
- } else if (mlme->state==htons(DOT11_STATE_ASSOC)) {
- if (len < sizeof(pimdev_hdr) + sizeof(struct obj_mlme)) {
- printf("bad assoc packet\n");
- return;
- }
- mac_id = mac_id_get(drv, mlme->id);
- if (mac_id == NULL)
- return;
- memcpy(&mlme->address[0], mac_id, ETH_ALEN);
- sta = ap_get_sta(drv->hapd, (u8 *) &mlme->address[0]);
- if (sta == NULL) {
- printf("cannot get sta\n");
- return;
- }
- new_assoc = (sta->flags & WLAN_STA_ASSOC) == 0;
- sta->flags |= WLAN_STA_AUTH | WLAN_STA_ASSOC;
- wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC);
- hostapd_new_assoc_sta(drv->hapd, sta, !new_assoc);
- ieee802_1x_notify_port_enabled(sta->eapol_sm, 1);
- sta->timeout_next = STA_NULLFUNC;
- return;
- }
- return;
-
-fail:
- printf("Prism54: assoc fail: %x\n", resp);
- mlme->code = host_to_le16(resp);
- mlme->size = 0;
- mlme->state = htons(DOT11_STATE_ASSOCING);
- hdr->oid = htonl(DOT11_OID_DISASSOCIATEEX);
- hdr->op = htonl(PIMOP_SET);
- sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
- send(drv->pim_sock, hdr, sizeof(*hdr) + sizeof(*mlme), 0);
-}
-
-
-static void handle_pim(int sock, void *eloop_ctx, void *sock_ctx)
-{
- struct prism54_driver_data *drv = eloop_ctx;
- int len;
- pimdev_hdr *hdr;
-
- hdr = malloc(PIM_BUF_SIZE);
- if (hdr == NULL)
- return;
- len = recv(sock, hdr, PIM_BUF_SIZE, 0);
- if (len < 0) {
- perror("recv");
- free(hdr);
- return;
- }
- if (len < 8) {
- printf("handle_pim: too short (%d)\n", len);
- free(hdr);
- return;
- }
-
- if (hdr->op != (int) htonl(PIMOP_TRAP)) {
- free(hdr);
- return;
- }
- switch (ntohl(hdr->oid)) {
- case DOT11_OID_PROBE:
- prism54_handle_probe(drv, hdr, len);
- break;
- case DOT11_OID_DEAUTHENTICATEEX:
- case DOT11_OID_DEAUTHENTICATE:
- prism54_handle_deauth(drv, hdr, len);
- break;
- case DOT11_OID_DISASSOCIATEEX:
- case DOT11_OID_DISASSOCIATE:
- prism54_handle_disassoc(drv, hdr, len);
- break;
- case DOT11_OID_AUTHENTICATEEX:
- case DOT11_OID_AUTHENTICATE:
- prism54_handle_auth(drv, hdr, len);
- break;
- case DOT11_OID_ASSOCIATEEX:
- case DOT11_OID_REASSOCIATEEX:
- case DOT11_OID_ASSOCIATE:
- case DOT11_OID_REASSOCIATE:
- prism54_handle_assoc(drv, hdr, len);
- default:
- break;
- }
-
- free(hdr);
-}
-
-
-static void handle_802_3(int sock, void *eloop_ctx, void *sock_ctx)
-{
- struct hostapd_data *hapd = (struct hostapd_data *) eloop_ctx;
- int len;
- ieee802_3_hdr *hdr;
-
- hdr = malloc(PIM_BUF_SIZE);
- if (hdr == NULL)
- return;
- len = recv(sock, hdr, PIM_BUF_SIZE, 0);
- if (len < 0) {
- perror("recv");
- free(hdr);
- return;
- }
- if (len < 14) {
- wpa_printf(MSG_MSGDUMP, "handle_802_3: too short (%d)", len);
- free(hdr);
- return;
- }
- if (hdr->type == htons(ETH_P_PAE)) {
- ieee802_1x_receive(hapd, (u8 *) &hdr->sa[0], (u8 *) &hdr[1],
- len - sizeof(*hdr));
- }
- free(hdr);
-}
-
-
-static int prism54_init_sockets(struct prism54_driver_data *drv)
-{
- struct hostapd_data *hapd = drv->hapd;
- struct ifreq ifr;
- struct sockaddr_ll addr;
-
- drv->sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_PAE));
- if (drv->sock < 0) {
- perror("socket[PF_PACKET,SOCK_RAW]");
- return -1;
- }
-
- if (eloop_register_read_sock(drv->sock, handle_802_3, drv->hapd, NULL))
- {
- printf("Could not register read socket\n");
- return -1;
- }
-
- memset(&ifr, 0, sizeof(ifr));
- if (hapd->conf->bridge[0] != '\0') {
- printf("opening bridge: %s\n", hapd->conf->bridge);
- os_strlcpy(ifr.ifr_name, hapd->conf->bridge,
- sizeof(ifr.ifr_name));
- } else {
- os_strlcpy(ifr.ifr_name, drv->iface, sizeof(ifr.ifr_name));
- }
- if (ioctl(drv->sock, SIOCGIFINDEX, &ifr) != 0) {
- perror("ioctl(SIOCGIFINDEX)");
- return -1;
- }
-
- memset(&addr, 0, sizeof(addr));
- addr.sll_family = AF_PACKET;
- addr.sll_ifindex = ifr.ifr_ifindex;
- addr.sll_protocol = htons(ETH_P_PAE);
- wpa_printf(MSG_DEBUG, "Opening raw packet socket for ifindex %d",
- addr.sll_ifindex);
-
- if (bind(drv->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
- perror("bind");
- return -1;
- }
-
- memset(&ifr, 0, sizeof(ifr));
- os_strlcpy(ifr.ifr_name, drv->iface, sizeof(ifr.ifr_name));
- if (ioctl(drv->sock, SIOCGIFHWADDR, &ifr) != 0) {
- perror("ioctl(SIOCGIFHWADDR)");
- return -1;
- }
-
- if (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) {
- printf("Invalid HW-addr family 0x%04x\n",
- ifr.ifr_hwaddr.sa_family);
- return -1;
- }
- memcpy(drv->hapd->own_addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
-
- drv->pim_sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
- if (drv->pim_sock < 0) {
- perror("socket[PF_PACKET,SOCK_RAW]");
- return -1;
- }
-
- if (eloop_register_read_sock(drv->pim_sock, handle_pim, drv, NULL)) {
- printf("Could not register read socket\n");
- return -1;
- }
-
- memset(&ifr, 0, sizeof(ifr));
- snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%sap", drv->iface);
- if (ioctl(drv->pim_sock, SIOCGIFINDEX, &ifr) != 0) {
- perror("ioctl(SIOCGIFINDEX)");
- return -1;
- }
-
- memset(&addr, 0, sizeof(addr));
- addr.sll_family = AF_PACKET;
- addr.sll_ifindex = ifr.ifr_ifindex;
- addr.sll_protocol = htons(ETH_P_ALL);
- wpa_printf(MSG_DEBUG, "Opening raw packet socket for ifindex %d",
- addr.sll_ifindex);
-
- if (bind(drv->pim_sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
- perror("bind");
- return -1;
- }
-
- return 0;
-}
-
-
-static void * prism54_driver_init(struct hostapd_data *hapd)
-{
- struct prism54_driver_data *drv;
-
- drv = os_zalloc(sizeof(struct prism54_driver_data));
- if (drv == NULL) {
- printf("Could not allocate memory for hostapd Prism54 driver "
- "data\n");
- return NULL;
- }
-
- drv->hapd = hapd;
- drv->pim_sock = drv->sock = -1;
- memcpy(drv->iface, hapd->conf->iface, sizeof(drv->iface));
-
- if (prism54_init_sockets(drv)) {
- free(drv);
- return NULL;
- }
- prism54_init_1x(drv);
- /* must clean previous elems */
- prism54_set_generic_elem(drv->iface, drv, NULL, 0);
-
- return drv;
-}
-
-
-static void prism54_driver_deinit(void *priv)
-{
- struct prism54_driver_data *drv = priv;
-
- if (drv->pim_sock >= 0)
- close(drv->pim_sock);
-
- if (drv->sock >= 0)
- close(drv->sock);
-
- free(drv);
-}
-
-
-const struct wpa_driver_ops wpa_driver_prism54_ops = {
- .name = "prism54",
- .init = prism54_driver_init,
- .deinit = prism54_driver_deinit,
- /* .set_ieee8021x = prism54_init_1x, */
- .set_privacy = prism54_set_privacy_invoked,
- .set_encryption = prism54_set_encryption,
- .get_seqnum = prism54_get_seqnum,
- .flush = prism54_flush,
- .set_generic_elem = prism54_set_generic_elem,
- .send_eapol = prism54_send_eapol,
- .sta_set_flags = prism54_sta_set_flags,
- .sta_deauth = prism54_sta_deauth,
- .sta_disassoc = prism54_sta_disassoc,
- .set_ssid = prism54_ioctl_setiwessid,
- .get_inact_sec = prism54_get_inact_sec,
-};
diff --git a/hostapd/driver_test.c b/hostapd/driver_test.c
deleted file mode 100644
index 9930a8284755..000000000000
--- a/hostapd/driver_test.c
+++ /dev/null
@@ -1,1300 +0,0 @@
-/*
- * hostapd / Driver interface for development testing
- * Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Alternatively, this software may be distributed under the terms of BSD
- * license.
- *
- * See README and COPYING for more details.
- */
-
-#include "includes.h"
-#include <sys/un.h>
-#include <dirent.h>
-
-#include "hostapd.h"
-#include "driver.h"
-#include "sha1.h"
-#include "eloop.h"
-#include "ieee802_1x.h"
-#include "sta_info.h"
-#include "wpa.h"
-#include "accounting.h"
-#include "radius/radius.h"
-#include "l2_packet/l2_packet.h"
-#include "ieee802_11.h"
-#include "hw_features.h"
-#include "wps_hostapd.h"
-
-
-struct test_client_socket {
- struct test_client_socket *next;
- u8 addr[ETH_ALEN];
- struct sockaddr_un un;
- socklen_t unlen;
- struct test_driver_bss *bss;
-};
-
-struct test_driver_bss {
- struct test_driver_bss *next;
- char ifname[IFNAMSIZ + 1];
- u8 bssid[ETH_ALEN];
- u8 *ie;
- size_t ielen;
- u8 *wps_beacon_ie;
- size_t wps_beacon_ie_len;
- u8 *wps_probe_resp_ie;
- size_t wps_probe_resp_ie_len;
- u8 ssid[32];
- size_t ssid_len;
- int privacy;
-};
-
-struct test_driver_data {
- struct hostapd_data *hapd;
- struct test_client_socket *cli;
- int test_socket;
- struct test_driver_bss *bss;
- char *socket_dir;
- char *own_socket_path;
- int udp_port;
-};
-
-
-static void test_driver_free_bss(struct test_driver_bss *bss)
-{
- free(bss->ie);
- free(bss->wps_beacon_ie);
- free(bss->wps_probe_resp_ie);
- free(bss);
-}
-
-
-static void test_driver_free_priv(struct test_driver_data *drv)
-{
- struct test_driver_bss *bss, *prev;
-
- if (drv == NULL)
- return;
-
- bss = drv->bss;
- while (bss) {
- prev = bss;
- bss = bss->next;
- test_driver_free_bss(prev);
- }
- free(drv->own_socket_path);
- free(drv->socket_dir);
- free(drv);
-}
-
-
-static struct test_client_socket *
-test_driver_get_cli(struct test_driver_data *drv, struct sockaddr_un *from,
- socklen_t fromlen)
-{
- struct test_client_socket *cli = drv->cli;
-
- while (cli) {
- if (cli->unlen == fromlen &&
- strncmp(cli->un.sun_path, from->sun_path,
- fromlen - sizeof(cli->un.sun_family)) == 0)
- return cli;
- cli = cli->next;
- }
-
- return NULL;
-}
-
-
-static int test_driver_send_eapol(void *priv, const u8 *addr, const u8 *data,
- size_t data_len, int encrypt,
- const u8 *own_addr)
-{
- struct test_driver_data *drv = priv;
- struct test_client_socket *cli;
- struct msghdr msg;
- struct iovec io[3];
- struct l2_ethhdr eth;
-
- if (drv->test_socket < 0)
- return -1;
-
- cli = drv->cli;
- while (cli) {
- if (memcmp(cli->addr, addr, ETH_ALEN) == 0)
- break;
- cli = cli->next;
- }
-
- if (!cli) {
- wpa_printf(MSG_DEBUG, "%s: no destination client entry",
- __func__);
- return -1;
- }
-
- memcpy(eth.h_dest, addr, ETH_ALEN);
- memcpy(eth.h_source, own_addr, ETH_ALEN);
- eth.h_proto = host_to_be16(ETH_P_EAPOL);
-
- io[0].iov_base = "EAPOL ";
- io[0].iov_len = 6;
- io[1].iov_base = &eth;
- io[1].iov_len = sizeof(eth);
- io[2].iov_base = (u8 *) data;
- io[2].iov_len = data_len;
-
- memset(&msg, 0, sizeof(msg));
- msg.msg_iov = io;
- msg.msg_iovlen = 3;
- msg.msg_name = &cli->un;
- msg.msg_namelen = cli->unlen;
- return sendmsg(drv->test_socket, &msg, 0);
-}
-
-
-static int test_driver_send_ether(void *priv, const u8 *dst, const u8 *src,
- u16 proto, const u8 *data, size_t data_len)
-{
- struct test_driver_data *drv = priv;
- struct msghdr msg;
- struct iovec io[3];
- struct l2_ethhdr eth;
- char desttxt[30];
- struct sockaddr_un addr;
- struct dirent *dent;
- DIR *dir;
- int ret = 0, broadcast = 0, count = 0;
-
- if (drv->test_socket < 0 || drv->socket_dir == NULL) {
- wpa_printf(MSG_DEBUG, "%s: invalid parameters (sock=%d "
- "socket_dir=%p)",
- __func__, drv->test_socket, drv->socket_dir);
- return -1;
- }
-
- broadcast = memcmp(dst, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) == 0;
- snprintf(desttxt, sizeof(desttxt), MACSTR, MAC2STR(dst));
-
- memcpy(eth.h_dest, dst, ETH_ALEN);
- memcpy(eth.h_source, src, ETH_ALEN);
- eth.h_proto = host_to_be16(proto);
-
- io[0].iov_base = "ETHER ";
- io[0].iov_len = 6;
- io[1].iov_base = &eth;
- io[1].iov_len = sizeof(eth);
- io[2].iov_base = (u8 *) data;
- io[2].iov_len = data_len;
-
- memset(&msg, 0, sizeof(msg));
- msg.msg_iov = io;
- msg.msg_iovlen = 3;
-
- dir = opendir(drv->socket_dir);
- if (dir == NULL) {
- perror("test_driver: opendir");
- return -1;
- }
- while ((dent = readdir(dir))) {
-#ifdef _DIRENT_HAVE_D_TYPE
- /* Skip the file if it is not a socket. Also accept
- * DT_UNKNOWN (0) in case the C library or underlying file
- * system does not support d_type. */
- if (dent->d_type != DT_SOCK && dent->d_type != DT_UNKNOWN)
- continue;
-#endif /* _DIRENT_HAVE_D_TYPE */
- if (strcmp(dent->d_name, ".") == 0 ||
- strcmp(dent->d_name, "..") == 0)
- continue;
-
- memset(&addr, 0, sizeof(addr));
- addr.sun_family = AF_UNIX;
- snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%s",
- drv->socket_dir, dent->d_name);
-
- if (strcmp(addr.sun_path, drv->own_socket_path) == 0)
- continue;
- if (!broadcast && strstr(dent->d_name, desttxt) == NULL)
- continue;
-
- wpa_printf(MSG_DEBUG, "%s: Send ether frame to %s",
- __func__, dent->d_name);
-
- msg.msg_name = &addr;
- msg.msg_namelen = sizeof(addr);
- ret = sendmsg(drv->test_socket, &msg, 0);
- if (ret < 0)
- perror("driver_test: sendmsg");
- count++;
- }
- closedir(dir);
-
- if (!broadcast && count == 0) {
- wpa_printf(MSG_DEBUG, "%s: Destination " MACSTR " not found",
- __func__, MAC2STR(dst));
- return -1;
- }
-
- return ret;
-}
-
-
-static int test_driver_send_mgmt_frame(void *priv, const void *buf,
- size_t len, int flags)
-{
- struct test_driver_data *drv = priv;
- struct msghdr msg;
- struct iovec io[2];
- const u8 *dest;
- int ret = 0, broadcast = 0;
- char desttxt[30];
- struct sockaddr_un addr;
- struct dirent *dent;
- DIR *dir;
- struct ieee80211_hdr *hdr;
- u16 fc;
-
- if (drv->test_socket < 0 || len < 10 || drv->socket_dir == NULL) {
- wpa_printf(MSG_DEBUG, "%s: invalid parameters (sock=%d len=%lu"
- " socket_dir=%p)",
- __func__, drv->test_socket, (unsigned long) len,
- drv->socket_dir);
- return -1;
- }
-
- dest = buf;
- dest += 4;
- broadcast = memcmp(dest, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) == 0;
- snprintf(desttxt, sizeof(desttxt), MACSTR, MAC2STR(dest));
-
- io[0].iov_base = "MLME ";
- io[0].iov_len = 5;
- io[1].iov_base = (void *) buf;
- io[1].iov_len = len;
-
- memset(&msg, 0, sizeof(msg));
- msg.msg_iov = io;
- msg.msg_iovlen = 2;
-
- dir = opendir(drv->socket_dir);
- if (dir == NULL) {
- perror("test_driver: opendir");
- return -1;
- }
- while ((dent = readdir(dir))) {
-#ifdef _DIRENT_HAVE_D_TYPE
- /* Skip the file if it is not a socket. Also accept
- * DT_UNKNOWN (0) in case the C library or underlying file
- * system does not support d_type. */
- if (dent->d_type != DT_SOCK && dent->d_type != DT_UNKNOWN)
- continue;
-#endif /* _DIRENT_HAVE_D_TYPE */
- if (strcmp(dent->d_name, ".") == 0 ||
- strcmp(dent->d_name, "..") == 0)
- continue;
-
- memset(&addr, 0, sizeof(addr));
- addr.sun_family = AF_UNIX;
-