CharonVpnService provides a function to get trusted certificates via JNI
[strongswan.git] / src / frontends / android / jni / libandroidbridge / charonservice.h
1 /*
2 * Copyright (C) 2012 Tobias Brunner
3 * Copyright (C) 2012 Giuliano Grassi
4 * Copyright (C) 2012 Ralf Sager
5 * Hochschule fuer Technik Rapperswil
6 *
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>.
11 *
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
15 * for more details.
16 */
17
18 /**
19 * @defgroup libandroidbridge libandroidbridge
20 *
21 * @defgroup android_kernel kernel
22 * @ingroup libandroidbridge
23 *
24 * @defgroup charonservice charonservice
25 * @{ @ingroup libandroidbridge
26 */
27
28 #ifndef CHARONSERVICE_H_
29 #define CHARONSERVICE_H_
30
31 #include <library.h>
32 #include <utils/linked_list.h>
33
34 typedef enum android_vpn_state_t android_vpn_state_t;
35 typedef struct charonservice_t charonservice_t;
36
37 /**
38 * VPN status codes. As defined in CharonVpnService.java
39 */
40 enum android_vpn_state_t {
41 CHARONSERVICE_CHILD_STATE_UP = 1,
42 CHARONSERVICE_CHILD_STATE_DOWN,
43 CHARONSERVICE_AUTH_ERROR,
44 CHARONSERVICE_PEER_AUTH_ERROR,
45 CHARONSERVICE_LOOKUP_ERROR,
46 CHARONSERVICE_UNREACHABLE_ERROR,
47 CHARONSERVICE_GENERIC_ERROR,
48 };
49
50 /**
51 * Public interface of charonservice.
52 *
53 * Used to communicate with CharonVpnService via JNI
54 */
55 struct charonservice_t {
56
57 /**
58 * Update the status in the Java domain (UI)
59 *
60 * @param code status code
61 * @return TRUE on success
62 */
63 bool (*update_status)(charonservice_t *this, android_vpn_state_t code);
64
65 /**
66 * Install a bypass policy for the given socket using the protect() Method
67 * of the Android VpnService interface
68 *
69 * @param fd socket file descriptor
70 * @param family socket protocol family
71 * @return TRUE if operation successful
72 */
73 bool (*bypass_socket)(charonservice_t *this, int fd, int family);
74
75 /**
76 * Get a list of trusted certificates via JNI
77 *
78 * @return list of DER encoded certificates (as chunk_t*),
79 * NULL on failure
80 */
81 linked_list_t *(*get_trusted_certificates)(charonservice_t *this);
82
83 };
84
85 /**
86 * The single instance of charonservice_t.
87 *
88 * Set between JNI calls to initializeCharon() and deinitializeCharon().
89 */
90 extern charonservice_t *charonservice;
91
92 #endif /** CHARONSERVICE_H_ @}*/