#include <string.h>
#include <android/log.h>
+#include "charonservice.h"
#include "android_jni.h"
#include <daemon.h>
#include <ipsec.h>
#include <library.h>
+typedef struct private_charonservice_t private_charonservice_t;
+
+/**
+ * private data of charonservice
+ */
+struct private_charonservice_t {
+
+ /**
+ * public interface
+ */
+ charonservice_t public;
+};
+
+/**
+ * Single instance of charonservice_t.
+ */
+charonservice_t *charonservice;
/**
* hook in library for debugging messages
}
}
+/**
+ * Initialize the charonservice object
+ */
+static void charonservice_init()
+{
+ private_charonservice_t *this;
+
+ INIT(this,
+ .public = {
+ },
+ );
+ charonservice = &this->public;
+}
+
+/**
+ * Deinitialize the charonservice object
+ */
+static void charonservice_deinit()
+{
+ private_charonservice_t *this = (private_charonservice_t*)charonservice;
+
+ free(this);
+ charonservice = NULL;
+}
+
/**
* Initialize charon and the libraries via JNI
*/
return;
}
+ charonservice_init();
+
if (!libcharon_init("charon") ||
!charon->initialize(charon, PLUGINS))
{
libcharon_deinit();
+ charonservice_deinit();
libipsec_deinit();
libhydra_deinit();
library_deinit();
}
/**
- * Initialize charon and the libraries via JNI
+ * Deinitialize charon and all libraries
*/
JNI_METHOD(CharonVpnService, deinitializeCharon, void)
{
libcharon_deinit();
+ charonservice_deinit();
libipsec_deinit();
libhydra_deinit();
library_deinit();
--- /dev/null
+/*
+ * Copyright (C) 2012 Tobias Brunner
+ * Copyright (C) 2012 Giuliano Grassi
+ * Copyright (C) 2012 Ralf Sager
+ * 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 libandroidbridge libandroidbridge
+ *
+ * @defgroup charonservice charonservice
+ * @{ @ingroup libandroidbridge
+ */
+
+#ifndef CHARONSERVICE_H_
+#define CHARONSERVICE_H_
+
+typedef struct charonservice_t charonservice_t;
+
+/**
+ * Public interface of charonservice.
+ *
+ * Used to communicate with CharonVpnService via JNI
+ */
+struct charonservice_t {
+
+};
+
+/**
+ * The single instance of charonservice_t.
+ *
+ * Set between JNI calls to initializeCharon() and deinitializeCharon().
+ */
+extern charonservice_t *charonservice;
+
+#endif /** CHARONSERVICE_H_ @}*/