2 * Copyright (C) 2012 Giuliano Grassi
3 * Copyright (C) 2012 Ralf Sager
4 * Copyright (C) 2012 Tobias Brunner
5 * Hochschule fuer Technik Rapperswil
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 #include <android/log.h>
21 #include "android_jni.h"
30 * hook in library for debugging messages
32 extern void (*dbg
)(debug_t group
, level_t level
, char *fmt
, ...);
35 * Logging hook for library logs, using android specific logging
37 static void dbg_android(debug_t group
, level_t level
, char *fmt
, ...)
43 char sgroup
[16], buffer
[8192];
44 char *current
= buffer
, *next
;
45 snprintf(sgroup
, sizeof(sgroup
), "%N", debug_names
, group
);
47 vsnprintf(buffer
, sizeof(buffer
), fmt
, args
);
50 { /* log each line separately */
51 next
= strchr(current
, '\n');
56 __android_log_print(ANDROID_LOG_INFO
, "charon", "00[%s] %s\n",
64 * Initialize charon and the libraries via JNI
66 JNI_METHOD(CharonVpnService
, initializeCharon
, void)
68 /* logging for library during initialization, as we have no bus yet */
71 /* initialize library */
72 if (!library_init(NULL
))
78 if (!libhydra_init("charon"))
93 if (!libcharon_init("charon") ||
94 !charon
->initialize(charon
, PLUGINS
))
103 /* start daemon (i.e. the threads in the thread-pool) */
104 charon
->start(charon
);
108 * Initialize charon and the libraries via JNI
110 JNI_METHOD(CharonVpnService
, deinitializeCharon
, void)