Import WPA from FreeBSD
We need WPA source files to compile and implement the wpa_supplicant.
We can get the wpa source code from their web site:
https://w1.fi/wpa_supplicant/
For RTEMS-libbsd, we can directly import it from FreeBSD.
1.Firstly, we need add these imported files in libbsd.py.
We create a new module named :usr_sbin_wpa_supplicant, and add files in this module:
+# /usr/sbin/wpa_supplicant
+#
+def usr_sbin_wpa_supplicant(mm):
+ mod = builder.Module('usr_sbin_wpa_supplicant')
+ mod.addUserSpaceHeaderFiles(
+ [
+ 'contrib/wpa/wpa_supplicant/ap.h',
+ 'contrib/wpa/wpa_supplicant/blacklist.h',
+ 'contrib/wpa/wpa_supplicant/bss.h',
+ 'contrib/wpa/wpa_supplicant/config.h',
+ 'contrib/wpa/wpa_supplicant/config_ssid.h',
+ 'contrib/wpa/wpa_supplicant/ctrl_iface.h',
+ 'contrib/wpa/wpa_supplicant/driver_i.h',
+ 'contrib/wpa/wpa_supplicant/gas_query.h',
+ 'contrib/wpa/wpa_supplicant/hs20_supplicant.h',
+ 'contrib/wpa/wpa_supplicant/interworking.h',
+ 'contrib/wpa/wpa_supplicant/mesh.h',
+ 'contrib/wpa/wpa_supplicant/mesh_mpm.h',
+ 'contrib/wpa/wpa_supplicant/mesh_rsn.h',
+ 'contrib/wpa/wpa_supplicant/notify.h',
+ 'contrib/wpa/wpa_supplicant/offchannel.h',
+ 'contrib/wpa/wpa_supplicant/scan.h',
+ 'contrib/wpa/wpa_supplicant/autoscan.h',
+ 'contrib/wpa/wpa_supplicant/wmm_ac.h',
+ 'contrib/wpa/wpa_supplicant/wnm_sta.h',
+ 'contrib/wpa/wpa_supplicant/wpas_glue.h',
......
+ ]
+ )
+ mod.addUserSpaceSourceFiles(
+ [
+ 'contrib/wpa/wpa_supplicant/blacklist.c',
+ 'contrib/wpa/wpa_supplicant/bss.c',
+ 'contrib/wpa/wpa_supplicant/config.c',
+ 'contrib/wpa/wpa_supplicant/config_file.c',
+ 'contrib/wpa/wpa_supplicant/ctrl_iface.c',
+ 'contrib/wpa/wpa_supplicant/ctrl_iface_unix.c',
+ 'contrib/wpa/wpa_supplicant/eap_register.c',
+ 'contrib/wpa/wpa_supplicant/events.c',
+ 'contrib/wpa/wpa_supplicant/gas_query.c',
+ 'contrib/wpa/wpa_supplicant/hs20_supplicant.c',
+ 'contrib/wpa/wpa_supplicant/interworking.c',
+ 'contrib/wpa/wpa_supplicant/main.c',
+ 'contrib/wpa/wpa_supplicant/notify.c',
+ ],
2. Add the configure macro in mm.generator['source'], we need configure the source files to make sure it can run normally on RTEMS. For these configure macro, we can take the FreeBSD config files as a reference.
The configure file in FreeBSD/usr.sbin/wpa/wpa_supplicant/Makefile
CFLAGS+=-DCONFIG_BACKEND_FILE \
-DCONFIG_DEBUG_SYSLOG \
-DCONFIG_DRIVER_BSD \
-DCONFIG_DRIVER_NDIS \
-DCONFIG_DRIVER_WIRED \
-DCONFIG_GAS \
-DCONFIG_HS20 \
-DCONFIG_IEEE80211R \
-DCONFIG_INTERWORKING \
-DCONFIG_PEERKEY \
-DCONFIG_PRIVSEP \
-DCONFIG_SMARTCARD \
-DCONFIG_TERMINATE_ONLASTIF \
-DCONFIG_TLS=openssl \
-DCONFIG_WPS \
-DCONFIG_WPS2 \
-DCONFIG_WPS_UPNP \
-DPKCS12_FUNCS
What we need to do is add these configure macro in mm.generator['source'].
+ mm.generator['source'](['-D__FreeBSD__=1',
+ '-DCONFIG_BACKEND_FILE=1',
+ '-DCONFIG_DEBUG_SYSLOG=1',
+ '-DCONFIG_DRIVER_BSD=1',
+ '-DCONFIG_DRIVER_NDIS=1',
+ '-DCONFIG_DRIVER_WIRED=1',
+ '-DCONFIG_GAS=1',
+ '-DCONFIG_HS20=1',
+ '-DCONFIG_IEEE80211R=1',
+ '-DCONFIG_INTERWORKING=1',
+ '-DCONFIG_PEERKEY=1',
+ '-DCONFIG_PRIVSEP=1',
+ '-DCONFIG_SMARTCARD=1',
+ '-DCONFIG_TERMINATE_ONLASTIF=1',
+ '-DCONFIG_TLS=openssl',
+ '-DCONFIG_WPS=1',
+ '-DCONFIG_WPS2=1',
+ '-DCONFIG_WPS_UPNP=1',
+ '-DPKCS12_FUNCS=1',
+ '-DCONFIG_SHA256=1',
+ '-DCONFIG_CTRL_IFACE=1',
+ '-DCONFIG_CTRL_IFACE_UNIX=1',
+ '-DIEEE8021X_EAPOL=1',
+ '-DEAP_MD5=1',
+ '-DEAP_GTC=1',
+ '-DEAP_LEAP=1',
+ '-DEAP_MSCHAPv2=1',
+ '-DEAP_OTP=1',
+ '-DEAP_PEAP=1',
+ '-DEAP_PSK=1',
+ '-DEAP_TLS=1',
+ '-DEAP_TTLS=1'],
+ ['freebsd/contrib/wpa/src',
+ 'freebsd/contrib/wpa/src/utils',
+ 'freebsd/contrib/wpa/src/eap_peer',
+ 'freebsd/usr.sbin/wpa/wpa_supplicant',
+ 'freebsd/crypto/openssl/crypto'])
+ )
3. We need configure a wpa_supplicant command for RTEMS, so we add a command files in rtemsbsd.
+ mod.addRTEMSSourceFiles(
+ [
+ 'rtems/rtems-bsd-shell-wpa_supplicant.c',
+ ],
+ mm.generator['source']()
+ )
+ return mod
+
4. Last we need add this module into compile in libbsd.py
mm.addModule(contrib_expat(mm))
mm.addModule(contrib_libpcap(mm))
mm.addModule(usr_sbin_tcpdump(mm))
+ mm.addModule(usr_sbin_wpa_supplicant(mm))
mm.addModule(crypto_openssl(mm))
评论
发表评论