Added an Android specific credential set that provides CA 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_backend backend
22 * @ingroup libandroidbridge
23 *
24 * @defgroup android_kernel kernel
25 * @ingroup libandroidbridge
26 *
27 * @defgroup charonservice charonservice
28 * @{ @ingroup libandroidbridge
29 */
30
31 #ifndef CHARONSERVICE_H_
32 #define CHARONSERVICE_H_
33
34 #include <library.h>
35 #include <utils/linked_list.h>
36
37 typedef enum android_vpn_state_t android_vpn_state_t;
38 typedef struct charonservice_t charonservice_t;
39
40 /**
41 * VPN status codes. As defined in CharonVpnService.java
42 */
43 enum android_vpn_state_t {
44 CHARONSERVICE_CHILD_STATE_UP = 1,
45 CHARONSERVICE_CHILD_STATE_DOWN,
46 CHARONSERVICE_AUTH_ERROR,
47 CHARONSERVICE_PEER_AUTH_ERROR,
48 CHARONSERVICE_LOOKUP_ERROR,
49 CHARONSERVICE_UNREACHABLE_ERROR,
50 CHARONSERVICE_GENERIC_ERROR,
51 };
52
53 /**
54 * Public interface of charonservice.
55 *
56 * Used to communicate with CharonVpnService via JNI
57 */
58 struct charonservice_t {
59
60 /**
61 * Update the status in the Java domain (UI)
62 *
63 * @param code status code
64 * @return TRUE on success
65 */
66 bool (*update_status)(charonservice_t *this, android_vpn_state_t code);
67
68 /**
69 * Install a bypass policy for the given socket using the protect() Method
70 * of the Android VpnService interface
71 *
72 * @param fd socket file descriptor
73 * @param family socket protocol family
74 * @return TRUE if operation successful
75 */
76 bool (*bypass_socket)(charonservice_t *this, int fd, int family);
77
78 /**
79 * Get a list of trusted certificates via JNI
80 *
81 * @return list of DER encoded certificates (as chunk_t*),
82 * NULL on failure
83 */
84 linked_list_t *(*get_trusted_certificates)(charonservice_t *this);
85
86 };
87
88 /**
89 * The single instance of charonservice_t.
90 *
91 * Set between JNI calls to initializeCharon() and deinitializeCharon().
92 */
93 extern charonservice_t *charonservice;
94
95 #endif /** CHARONSERVICE_H_ @}*/