diff options
-rw-r--r-- | Android.mk.in | 4 | ||||
-rw-r--r-- | configure.in | 4 | ||||
-rw-r--r-- | man/strongswan.conf.5.in | 2 | ||||
-rw-r--r-- | src/libcharon/Android.mk | 6 | ||||
-rw-r--r-- | src/libcharon/Makefile.am | 7 | ||||
-rw-r--r-- | src/libcharon/plugins/android/Makefile.am | 1 | ||||
-rw-r--r-- | src/libcharon/plugins/android/android_plugin.c | 10 | ||||
-rw-r--r-- | src/libcharon/plugins/android_log/Makefile.am | 17 | ||||
-rw-r--r-- | src/libcharon/plugins/android_log/android_log_logger.c (renamed from src/libcharon/plugins/android/android_logger.c) | 24 | ||||
-rw-r--r-- | src/libcharon/plugins/android_log/android_log_logger.h (renamed from src/libcharon/plugins/android/android_logger.h) | 18 | ||||
-rw-r--r-- | src/libcharon/plugins/android_log/android_log_plugin.c | 76 | ||||
-rw-r--r-- | src/libcharon/plugins/android_log/android_log_plugin.h | 42 |
12 files changed, 175 insertions, 36 deletions
diff --git a/Android.mk.in b/Android.mk.in index a1ce1c571..19048b9e7 100644 --- a/Android.mk.in +++ b/Android.mk.in @@ -16,8 +16,8 @@ include $(CLEAR_VARS) # this is the list of plugins that are built into libstrongswan and charon # also these plugins are loaded by default (if not changed in strongswan.conf) -strongswan_CHARON_PLUGINS := openssl fips-prf random nonce pubkey pkcs1 \ - pem xcbc hmac kernel-netlink socket-default android \ +strongswan_CHARON_PLUGINS := android-log openssl fips-prf random nonce pubkey \ + pkcs1 pem xcbc hmac kernel-netlink socket-default android \ stroke eap-identity eap-mschapv2 eap-md5 ifneq ($(strongswan_BUILD_SCEPCLIENT),) diff --git a/configure.in b/configure.in index 0c288f82e..96b1fe373 100644 --- a/configure.in +++ b/configure.in @@ -206,6 +206,7 @@ ARG_ENABL_SET([gcm], [enables the GCM AEAD wrapper crypto plugin.]) ARG_ENABL_SET([addrblock], [enables RFC 3779 address block constraint support.]) ARG_ENABL_SET([uci], [enable OpenWRT UCI configuration plugin.]) ARG_ENABL_SET([android], [enable Android specific plugin.]) +ARG_ENABL_SET([android-log], [enable Android specific logger plugin.]) ARG_ENABL_SET([maemo], [enable Maemo specific plugin.]) ARG_ENABL_SET([nm], [enable NetworkManager backend.]) ARG_ENABL_SET([ha], [enable high availability cluster plugin.]) @@ -935,6 +936,7 @@ ADD_PLUGIN([medsrv], [c charon]) ADD_PLUGIN([medcli], [c charon]) ADD_PLUGIN([dhcp], [c charon]) ADD_PLUGIN([android], [c charon]) +ADD_PLUGIN([android-log], [c charon]) ADD_PLUGIN([ha], [c charon]) ADD_PLUGIN([whitelist], [c charon]) ADD_PLUGIN([certexpire], [c charon]) @@ -1016,6 +1018,7 @@ AM_CONDITIONAL(USE_MEDSRV, test x$medsrv = xtrue) AM_CONDITIONAL(USE_MEDCLI, test x$medcli = xtrue) AM_CONDITIONAL(USE_UCI, test x$uci = xtrue) AM_CONDITIONAL(USE_ANDROID, test x$android = xtrue) +AM_CONDITIONAL(USE_ANDROID_LOG, test x$android_log = xtrue) AM_CONDITIONAL(USE_MAEMO, test x$maemo = xtrue) AM_CONDITIONAL(USE_SMP, test x$smp = xtrue) AM_CONDITIONAL(USE_SQL, test x$sql = xtrue) @@ -1253,6 +1256,7 @@ AC_OUTPUT( src/libcharon/plugins/coupling/Makefile src/libcharon/plugins/radattr/Makefile src/libcharon/plugins/android/Makefile + src/libcharon/plugins/android_log/Makefile src/libcharon/plugins/maemo/Makefile src/libcharon/plugins/stroke/Makefile src/libcharon/plugins/updown/Makefile diff --git a/man/strongswan.conf.5.in b/man/strongswan.conf.5.in index 1a4da0016..ee8f8a8dc 100644 --- a/man/strongswan.conf.5.in +++ b/man/strongswan.conf.5.in @@ -272,7 +272,7 @@ Section to define syslog loggers, see LOGGER CONFIGURATION Number of worker threads in charon .SS charon.plugins subsection .TP -.BR charon.plugins.android.loglevel " [1]" +.BR charon.plugins.android_log.loglevel " [1]" Loglevel for logging to Android specific logger .TP .BR charon.plugins.attr diff --git a/src/libcharon/Android.mk b/src/libcharon/Android.mk index 87a2e2240..5e93e235f 100644 --- a/src/libcharon/Android.mk +++ b/src/libcharon/Android.mk @@ -127,10 +127,14 @@ processing/jobs/adopt_children_job.c processing/jobs/adopt_children_job.h LOCAL_SRC_FILES += $(call add_plugin, android) ifneq ($(call plugin_enabled, android),) LOCAL_C_INCLUDES += frameworks/base/cmds/keystore -LOCAL_LDLIBS += -llog LOCAL_SHARED_LIBRARIES += libcutils endif +LOCAL_SRC_FILES += $(call add_plugin, android-log) +ifneq ($(call plugin_enabled, android-log),) +LOCAL_LDLIBS += -llog +endif + LOCAL_SRC_FILES += $(call add_plugin, attr) LOCAL_SRC_FILES += $(call add_plugin, eap-aka) diff --git a/src/libcharon/Makefile.am b/src/libcharon/Makefile.am index a254c0336..df23e22f6 100644 --- a/src/libcharon/Makefile.am +++ b/src/libcharon/Makefile.am @@ -456,6 +456,13 @@ if MONOLITHIC endif endif +if USE_ANDROID_LOG + SUBDIRS += plugins/android_log +if MONOLITHIC + libcharon_la_LIBADD += plugins/android_log/libstrongswan-android-log.la +endif +endif + if USE_MAEMO SUBDIRS += plugins/maemo if MONOLITHIC diff --git a/src/libcharon/plugins/android/Makefile.am b/src/libcharon/plugins/android/Makefile.am index b922ef4af..b10cd9527 100644 --- a/src/libcharon/plugins/android/Makefile.am +++ b/src/libcharon/plugins/android/Makefile.am @@ -14,7 +14,6 @@ libstrongswan_android_la_SOURCES = \ android_plugin.c android_plugin.h \ android_service.c android_service.h \ android_handler.c android_handler.h \ - android_logger.c android_logger.h \ android_creds.c android_creds.h libstrongswan_android_la_LDFLAGS = -module -avoid-version diff --git a/src/libcharon/plugins/android/android_plugin.c b/src/libcharon/plugins/android/android_plugin.c index bad8bc042..c0f58e9b4 100644 --- a/src/libcharon/plugins/android/android_plugin.c +++ b/src/libcharon/plugins/android/android_plugin.c @@ -15,7 +15,6 @@ */ #include "android_plugin.h" -#include "android_logger.h" #include "android_handler.h" #include "android_creds.h" #include "android_service.h" @@ -36,11 +35,6 @@ struct private_android_plugin_t { android_plugin_t public; /** - * Android specific logger - */ - android_logger_t *logger; - - /** * Android specific DNS handler */ android_handler_t *handler; @@ -68,10 +62,8 @@ METHOD(plugin_t, destroy, void, hydra->attributes->remove_handler(hydra->attributes, &this->handler->handler); lib->credmgr->remove_set(lib->credmgr, &this->creds->set); - charon->bus->remove_logger(charon->bus, &this->logger->logger); this->creds->destroy(this->creds); this->handler->destroy(this->handler); - this->logger->destroy(this->logger); DESTROY_IF(this->service); free(this); } @@ -91,14 +83,12 @@ plugin_t *android_plugin_create() .destroy = _destroy, }, }, - .logger = android_logger_create(), .creds = android_creds_create(), ); this->service = android_service_create(this->creds); this->handler = android_handler_create(this->service != NULL); - charon->bus->add_logger(charon->bus, &this->logger->logger); lib->credmgr->add_set(lib->credmgr, &this->creds->set); hydra->attributes->add_handler(hydra->attributes, &this->handler->handler); diff --git a/src/libcharon/plugins/android_log/Makefile.am b/src/libcharon/plugins/android_log/Makefile.am new file mode 100644 index 000000000..3c180f1db --- /dev/null +++ b/src/libcharon/plugins/android_log/Makefile.am @@ -0,0 +1,17 @@ + +INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libhydra \ + -I$(top_srcdir)/src/libcharon + +AM_CFLAGS = -rdynamic + +if MONOLITHIC +noinst_LTLIBRARIES = libstrongswan-android-log.la +else +plugin_LTLIBRARIES = libstrongswan-android-log.la +endif + +libstrongswan_android_log_la_SOURCES = \ + android_log_plugin.c android_log_plugin.h \ + android_log_logger.c android_log_logger.h + +libstrongswan_android_log_la_LDFLAGS = -module -avoid-version diff --git a/src/libcharon/plugins/android/android_logger.c b/src/libcharon/plugins/android_log/android_log_logger.c index 0c5f609f7..48bcaa577 100644 --- a/src/libcharon/plugins/android/android_logger.c +++ b/src/libcharon/plugins/android_log/android_log_logger.c @@ -16,23 +16,23 @@ #include <string.h> #include <android/log.h> -#include "android_logger.h" +#include "android_log_logger.h" #include <library.h> #include <daemon.h> #include <threading/mutex.h> -typedef struct private_android_logger_t private_android_logger_t; +typedef struct private_android_log_logger_t private_android_log_logger_t; /** - * Private data of an android_logger_t object + * Private data of an android_log_logger_t object */ -struct private_android_logger_t { +struct private_android_log_logger_t { /** * Public interface */ - android_logger_t public; + android_log_logger_t public; /** * logging level @@ -46,7 +46,7 @@ struct private_android_logger_t { }; METHOD(logger_t, log_, void, - private_android_logger_t *this, debug_t group, level_t level, + private_android_log_logger_t *this, debug_t group, level_t level, int thread, ike_sa_t* ike_sa, const char *message) { int prio = level > 1 ? ANDROID_LOG_DEBUG : ANDROID_LOG_INFO; @@ -71,13 +71,13 @@ METHOD(logger_t, log_, void, } METHOD(logger_t, get_level, level_t, - private_android_logger_t *this, debug_t group) + private_android_log_logger_t *this, debug_t group) { return this->level; } -METHOD(android_logger_t, destroy, void, - private_android_logger_t *this) +METHOD(android_log_logger_t, destroy, void, + private_android_log_logger_t *this) { this->mutex->destroy(this->mutex); free(this); @@ -86,9 +86,9 @@ METHOD(android_logger_t, destroy, void, /** * Described in header. */ -android_logger_t *android_logger_create() +android_log_logger_t *android_log_logger_create() { - private_android_logger_t *this; + private_android_log_logger_t *this; INIT(this, .public = { @@ -100,7 +100,7 @@ android_logger_t *android_logger_create() }, .mutex = mutex_create(MUTEX_TYPE_DEFAULT), .level = lib->settings->get_int(lib->settings, - "%s.plugins.android.loglevel", 1, charon->name), + "%s.plugins.android_log.loglevel", 1, charon->name), ); return &this->public; diff --git a/src/libcharon/plugins/android/android_logger.h b/src/libcharon/plugins/android_log/android_log_logger.h index 15abbb43f..ed271bf6c 100644 --- a/src/libcharon/plugins/android/android_logger.h +++ b/src/libcharon/plugins/android_log/android_log_logger.h @@ -14,21 +14,21 @@ */ /** - * @defgroup android_logger android_logger - * @{ @ingroup android + * @defgroup android_log_logger android_log_logger + * @{ @ingroup android_log */ -#ifndef ANDROID_LOGGER_H_ -#define ANDROID_LOGGER_H_ +#ifndef ANDROID_LOG_LOGGER_H_ +#define ANDROID_LOG_LOGGER_H_ #include <bus/bus.h> -typedef struct android_logger_t android_logger_t; +typedef struct android_log_logger_t android_log_logger_t; /** * Android specific logger. */ -struct android_logger_t { +struct android_log_logger_t { /** * Implements logger_t interface @@ -38,7 +38,7 @@ struct android_logger_t { /** * Destroy the logger. */ - void (*destroy)(android_logger_t *this); + void (*destroy)(android_log_logger_t *this); }; @@ -47,6 +47,6 @@ struct android_logger_t { * * @return logger instance */ -android_logger_t *android_logger_create(); +android_log_logger_t *android_log_logger_create(); -#endif /** ANDROID_LOGGER_H_ @}*/ +#endif /** ANDROID_LOG_LOGGER_H_ @}*/ diff --git a/src/libcharon/plugins/android_log/android_log_plugin.c b/src/libcharon/plugins/android_log/android_log_plugin.c new file mode 100644 index 000000000..6757c2210 --- /dev/null +++ b/src/libcharon/plugins/android_log/android_log_plugin.c @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2012 Tobias Brunner + * Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * 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. + */ + +#include "android_log_plugin.h" +#include "android_log_logger.h" + +#include <daemon.h> + +typedef struct private_android_log_plugin_t private_android_log_plugin_t; + +/** + * Private data of an android_log_plugin_t object. + */ +struct private_android_log_plugin_t { + + /** + * Public android_log_plugin_t interface. + */ + android_log_plugin_t public; + + /** + * Android specific logger + */ + android_log_logger_t *logger; + +}; + +METHOD(plugin_t, get_name, char*, + private_android_log_plugin_t *this) +{ + return "android-log"; +} + +METHOD(plugin_t, destroy, void, + private_android_log_plugin_t *this) +{ + charon->bus->remove_logger(charon->bus, &this->logger->logger); + this->logger->destroy(this->logger); + free(this); +} + +/** + * See header + */ +plugin_t *android_log_plugin_create() +{ + private_android_log_plugin_t *this; + + INIT(this, + .public = { + .plugin = { + .get_name = _get_name, + .reload = (void*)return_false, + .destroy = _destroy, + }, + }, + .logger = android_log_logger_create(), + ); + + charon->bus->add_logger(charon->bus, &this->logger->logger); + + return &this->public.plugin; +} + diff --git a/src/libcharon/plugins/android_log/android_log_plugin.h b/src/libcharon/plugins/android_log/android_log_plugin.h new file mode 100644 index 000000000..32c4dc10b --- /dev/null +++ b/src/libcharon/plugins/android_log/android_log_plugin.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2012 Tobias Brunner + * Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * 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. + */ + +/** + * @defgroup android_log android_log + * @ingroup cplugins + * + * @defgroup android_log_plugin android_log_plugin + * @{ @ingroup android_log + */ + +#ifndef ANDROID_LOG_PLUGIN_H_ +#define ANDROID_LOG_PLUGIN_H_ + +#include <plugins/plugin.h> + +typedef struct android_log_plugin_t android_log_plugin_t; + +/** + * Plugin providing an Android specific logger implementation. + */ +struct android_log_plugin_t { + + /** + * Implements plugin interface. + */ + plugin_t plugin; +}; + +#endif /** ANDROID_LOG_PLUGIN_H_ @}*/ |