1 From 3de5e59b291b6f58317bb16736f8c0271754378e Mon Sep 17 00:00:00 2001
2 From: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
3 Date: Sat, 2 Oct 2010 00:11:51 -0700
4 Subject: [PATCH] eap_peer: create a libeap library, with header files and pkg-config [v2]
6 This adds infrastructe in src/eap_peer to make libeap.so and install
7 the needed header files and pkg-config files.
9 Now, this is quite dirty and probably not what we want in the long
10 term, but serves as an starting point:
12 - we don't build from the wpa_supplicant directory because the
13 objects the .so have to be built with -fPIC. So if you need to
14 build both the binary and the library:
16 make -C wpa_supplicant
17 make -C src/eap_peer clean
20 As I said, it's dirty -- we'd need either wpa_supplicant linking
21 against the library properly (but that seems not to be desirable)
22 or a multiple object build approach ala automake.
24 - need to use 'override CFLAGS' in src/eap_peer/Makefile, otherwise
25 any CFLAGS setting will kill the build infrastructure. I miss
28 - adds 'eap_register_methods()' that will register every compiled in
31 Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
33 build_release | 12 +++
34 src/eap_peer/Makefile | 191 ++++++++++++++++++++++++++++++++++++++++++--
35 src/eap_peer/eap_methods.c | 114 ++++++++++++++++++++++++++
36 src/eap_peer/eap_methods.h | 1 +
37 src/eap_peer/libeap0.pc | 10 +++
38 5 files changed, 320 insertions(+), 8 deletions(-)
39 create mode 100644 src/eap_peer/libeap0.pc
41 diff --git a/src/eap_peer/Makefile b/src/eap_peer/Makefile
42 index 3651056..58c067a 100644
43 --- a/src/eap_peer/Makefile
44 +++ b/src/eap_peer/Makefile
47 - @echo Nothing to be made.
53 +LIBEAP = $(LIBEAP_NAME).so.$(LIBEAP_CURRENT).$(LIBEAP_REVISION).$(LIBEAP_AGE)
54 +LIBEAP_SO = $(LIBEAP_NAME).so.$(LIBEAP_CURRENT)
56 +.PHONY: all clean install uninstall
65 +CFLAGS = -MMD -O0 -Wall -g
70 +INCLUDE_INSTALL_DIR=/usr/include/eap_peer
72 +# Got to use override all across the board, otherwise a 'make
73 +# CFLAGS=XX' will kill us because the command line's CFLAGS will
74 +# overwrite Make's and we'll loose all the infrastructure it sets.
75 +override CFLAGS += -I. -I.. -I../crypto -I../utils -I../common
77 +# at least for now, need to include config_ssid.h and config_blob.h from
78 +# wpa_supplicant directory
79 +override CFLAGS += -I ../../wpa_supplicant
81 +OBJS_both += ../utils/common.o
82 +OBJS_both += ../utils/os_unix.o
83 +OBJS_both += ../utils/wpa_debug.o
84 +OBJS_both += ../utils/base64.o
85 +OBJS_both += ../utils/wpabuf.o
86 +OBJS_both += ../crypto/md5.o
87 +OBJS_both += ../crypto/sha1.o
88 +OBJS_both += ../crypto/sha1-tlsprf.o
89 +OBJS_both += ../crypto/aes-encblock.o
90 +OBJS_both += ../crypto/aes-wrap.o
91 +OBJS_both += ../crypto/aes-ctr.o
92 +OBJS_both += ../crypto/aes-eax.o
93 +OBJS_both += ../crypto/aes-omac1.o
94 +OBJS_both += ../crypto/ms_funcs.o
95 +OBJS_both += ../crypto/sha256.o
98 +OBJS_both += ../eap_common/eap_peap_common.o
99 +OBJS_both += ../eap_common/eap_psk_common.o
100 +OBJS_both += ../eap_common/eap_pax_common.o
101 +OBJS_both += ../eap_common/eap_sake_common.o
102 +OBJS_both += ../eap_common/eap_gpsk_common.o
103 +OBJS_both += ../eap_common/chap.o
105 +OBJS_peer += ../eap_peer/eap_tls.o
106 +OBJS_peer += ../eap_peer/eap_peap.o
107 +OBJS_peer += ../eap_peer/eap_ttls.o
108 +OBJS_peer += ../eap_peer/eap_md5.o
109 +OBJS_peer += ../eap_peer/eap_mschapv2.o
110 +OBJS_peer += ../eap_peer/mschapv2.o
111 +OBJS_peer += ../eap_peer/eap_otp.o
112 +OBJS_peer += ../eap_peer/eap_gtc.o
113 +OBJS_peer += ../eap_peer/eap_leap.o
114 +OBJS_peer += ../eap_peer/eap_psk.o
115 +OBJS_peer += ../eap_peer/eap_pax.o
116 +OBJS_peer += ../eap_peer/eap_sake.o
117 +OBJS_peer += ../eap_peer/eap_gpsk.o
118 +OBJS_peer += ../eap_peer/eap.o
119 +OBJS_peer += ../eap_common/eap_common.o
120 +OBJS_peer += ../eap_peer/eap_methods.o
121 +OBJS_peer += ../eap_peer/eap_tls_common.o
123 +override CFLAGS += -DEAP_TLS
124 +override CFLAGS += -DEAP_PEAP
125 +override CFLAGS += -DEAP_TTLS
126 +override CFLAGS += -DEAP_MD5
127 +override CFLAGS += -DEAP_MSCHAPv2
128 +override CFLAGS += -DEAP_GTC
129 +override CFLAGS += -DEAP_OTP
130 +override CFLAGS += -DEAP_LEAP
131 +override CFLAGS += -DEAP_PSK
132 +override CFLAGS += -DEAP_PAX
133 +override CFLAGS += -DEAP_SAKE
134 +override CFLAGS += -DEAP_GPSK -DEAP_GPSK_SHA256
135 +override CFLAGS += -DEAP_TLS_FUNCS
137 +override CFLAGS += -DIEEE8021X_EAPOL
139 +ifeq ($(CONFIG_TLS), openssl)
140 +override CFLAGS += -DEAP_TLS_OPENSSL
141 +OBJS_both += ../crypto/tls_openssl.o
142 +OBJS_both += ../crypto/crypto_openssl.o
143 +LIBS += -lssl -lcrypto
144 +override CFLAGS += -DINTERNAL_SHA256
147 +ifeq ($(CONFIG_TLS), internal)
148 +OBJS_both += ../crypto/tls_internal.o
149 +OBJS_both += ../tls/tlsv1_common.o ../../tls/tlsv1_record.o
150 +OBJS_both += ../tls/tlsv1_cred.o
151 +OBJS_both += ../tls/asn1.o ../../tls/x509v3.o
152 +OBJS_both += ../crypto/crypto_internal.o ../../tls/rsa.o ../../tls/bignum.o
154 +OBJS_peer += ../tls/tlsv1_client.o
155 +OBJS_peer += ../tls/tlsv1_client_write.o ../../tls/tlsv1_client_read.o
156 +override CFLAGS += -DCONFIG_TLS_INTERNAL_CLIENT
158 +OBJS_server += ../tls/tlsv1_server.o
159 +OBJS_server += ../tls/tlsv1_server_write.o ../../tls/tlsv1_server_read.o
160 +override CFLAGS += -DCONFIG_TLS_INTERNAL_SERVER
162 +override CFLAGS += -DCONFIG_TLS_INTERNAL
163 +override CFLAGS += -DCONFIG_CRYPTO_INTERNAL
164 +override CFLAGS += -DCONFIG_INTERNAL_X509
165 +override CFLAGS += -DINTERNAL_AES
166 +override CFLAGS += -DINTERNAL_SHA1
167 +override CFLAGS += -DINTERNAL_SHA256
168 +override CFLAGS += -DINTERNAL_MD5
169 +override CFLAGS += -DINTERNAL_MD4
170 +override CFLAGS += -DINTERNAL_DES
171 +ifdef CONFIG_INTERNAL_LIBTOMMATH
172 +override CFLAGS += -DCONFIG_INTERNAL_LIBTOMMATH
183 +OBJS_lib=$(OBJS_both) $(OBJS_peer)
187 +override CFLAGS += -fPIC -DPIC
190 +$(LIBEAP): $(OBJS_lib)
191 + $(LDO) $(LDFLAGS) $(OBJS_lib) -Wl,-soname -Wl,$(LIBEAP_SO) -o $(LIBEAP) $(LIBS)
194 +UTIL_HEADERS = ../utils/includes.h ../utils/common.h \
195 + ../utils/wpabuf.h ../utils/build_config.h \
196 + ../utils/os.h ../utils/wpa_debug.h
197 +COMMON_HEADERS = ../common/defs.h
198 +EAP_COMMON_HEADERS = ../eap_common/eap_defs.h
199 +MAIN_HEADERS = eap.h eap_methods.h eap_config.h
200 +CRYPTO_HEADERS = ../crypto/tls.h
204 + mkdir -p $(DESTDIR)/usr/lib
205 +# copy the lib file to std lib location
206 + cp $(LIBEAP) $(DESTDIR)/usr/lib
207 + ln -fs $(LIBEAP_SO) $(DESTDIR)/usr/lib/$(LIBEAP_NAME).so
209 +# copy the headers reqd by apps using eap peer library in its own subfolder under /usr/include
211 + $(DESTDIR)/$(INCLUDE_INSTALL_DIR)/eap_common \
212 + $(DESTDIR)/$(INCLUDE_INSTALL_DIR)/common \
213 + $(DESTDIR)/$(INCLUDE_INSTALL_DIR)/util \
214 + $(DESTDIR)/$(INCLUDE_INSTALL_DIR)/crypto
215 + install -m 0644 $(EAP_COMMON_HEADERS) $(DESTDIR)/$(INCLUDE_INSTALL_DIR)/eap_common
216 + install -m 0644 $(COMMON_HEADERS) $(DESTDIR)/$(INCLUDE_INSTALL_DIR)/common
217 + install -m 0644 $(CRYPTO_HEADERS) $(DESTDIR)/$(INCLUDE_INSTALL_DIR)/crypto
218 + install -m 0644 $(UTIL_HEADERS) $(DESTDIR)/$(INCLUDE_INSTALL_DIR)/util
219 + install -m 0644 $(MAIN_HEADERS) $(DESTDIR)/$(INCLUDE_INSTALL_DIR)/
221 + mkdir -p $(DESTDIR)/usr/lib/pkgconfig
222 + cp libeap0.pc $(DESTDIR)/usr/lib/pkgconfig
226 + rm $(DESTDIR)/usr/lib/$(LIBEAP)
227 + rm -fr $(DESTDIR)/$(INCLUDE_INSTALL_DIR)
228 + rm -f $(DESTDIR)/usr/lib/pkgconfig/libeap0.pc
231 - rm -f *~ *.o *.so *.d
232 + rm -f *~ *.o *.so *.d libeap.a $(LIBEAP) $(OBJS_lib)
235 - if ls *.so >/dev/null 2>&1; then \
236 - install -d $(DESTDIR)$(LIBDIR)/wpa_supplicant && \
237 - cp *.so $(DESTDIR)$(LIBDIR)/wpa_supplicant \
239 +-include $(OBJS:%.o=%.d)
240 diff --git a/src/eap_peer/eap_methods.c b/src/eap_peer/eap_methods.c
241 index 3b0af05..092f266 100644
242 --- a/src/eap_peer/eap_methods.c
243 +++ b/src/eap_peer/eap_methods.c
244 @@ -340,6 +340,120 @@ int eap_peer_method_register(struct eap_method *method)
248 + * eap_peer_register_methods - Register all known EAP peer methods
250 + * This function is called at program start to register all compiled
251 + * in EAP peer methods.
253 +int eap_peer_register_methods(void)
259 + ret = eap_peer_md5_register();
260 +#endif /* EAP_MD5 */
264 + ret = eap_peer_tls_register();
265 +#endif /* EAP_TLS */
269 + ret = eap_peer_mschapv2_register();
270 +#endif /* EAP_MSCHAPv2 */
274 + ret = eap_peer_peap_register();
275 +#endif /* EAP_PEAP */
279 + ret = eap_peer_ttls_register();
280 +#endif /* EAP_TTLS */
284 + ret = eap_peer_gtc_register();
285 +#endif /* EAP_GTC */
289 + ret = eap_peer_otp_register();
290 +#endif /* EAP_OTP */
294 + ret = eap_peer_sim_register();
295 +#endif /* EAP_SIM */
299 + ret = eap_peer_leap_register();
300 +#endif /* EAP_LEAP */
304 + ret = eap_peer_psk_register();
305 +#endif /* EAP_PSK */
309 + ret = eap_peer_aka_register();
310 +#endif /* EAP_AKA */
312 +#ifdef EAP_AKA_PRIME
314 + ret = eap_peer_aka_prime_register();
315 +#endif /* EAP_AKA_PRIME */
319 + ret = eap_peer_fast_register();
320 +#endif /* EAP_FAST */
324 + ret = eap_peer_pax_register();
325 +#endif /* EAP_PAX */
329 + ret = eap_peer_sake_register();
330 +#endif /* EAP_SAKE */
334 + ret = eap_peer_gpsk_register();
335 +#endif /* EAP_GPSK */
339 + ret = eap_peer_wsc_register();
340 +#endif /* EAP_WSC */
344 + ret = eap_peer_ikev2_register();
345 +#endif /* EAP_IKEV2 */
347 +#ifdef EAP_VENDOR_TEST
349 + ret = eap_peer_vendor_test_register();
350 +#endif /* EAP_VENDOR_TEST */
354 + ret = eap_peer_tnc_register();
355 +#endif /* EAP_TNC */
362 * eap_peer_unregister_methods - Unregister EAP peer methods
364 * This function is called at program termination to unregister all EAP peer
365 diff --git a/src/eap_peer/eap_methods.h b/src/eap_peer/eap_methods.h
366 index 384c61b..b83a46f 100644
367 --- a/src/eap_peer/eap_methods.h
368 +++ b/src/eap_peer/eap_methods.h
369 @@ -32,6 +32,7 @@ EapType eap_peer_get_type(const char *name, int *vendor);
370 const char * eap_get_name(int vendor, EapType type);
371 size_t eap_get_names(char *buf, size_t buflen);
372 char ** eap_get_names_as_string_array(size_t *num);
373 +int eap_peer_register_methods(void);
374 void eap_peer_unregister_methods(void);
376 #else /* IEEE8021X_EAPOL */
377 diff --git a/src/eap_peer/libeap0.pc b/src/eap_peer/libeap0.pc
379 index 0000000..2f8463a
381 +++ b/src/eap_peer/libeap0.pc
385 +libdir=${exec_prefix}/lib
386 +includedir=${prefix}/include
389 +Description: EAP Peer Library API
391 +Libs: -L${libdir} -leap
392 +Cflags: -I${includedir}