2 * Copyright (C) 2012 Tobias Brunner
3 * Copyright (C) 2012 Giuliano Grassi
4 * Copyright (C) 2012 Ralf Sager
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 * @defgroup libandroidbridge libandroidbridge
21 * @defgroup android_backend backend
22 * @ingroup libandroidbridge
24 * @defgroup android_kernel kernel
25 * @ingroup libandroidbridge
27 * @defgroup charonservice charonservice
28 * @{ @ingroup libandroidbridge
31 #ifndef CHARONSERVICE_H_
32 #define CHARONSERVICE_H_
34 #include "vpnservice_builder.h"
37 #include <utils/linked_list.h>
39 typedef enum android_vpn_state_t android_vpn_state_t
;
40 typedef struct charonservice_t charonservice_t
;
43 * VPN status codes. As defined in CharonVpnService.java
45 enum android_vpn_state_t
{
46 CHARONSERVICE_CHILD_STATE_UP
= 1,
47 CHARONSERVICE_CHILD_STATE_DOWN
,
48 CHARONSERVICE_AUTH_ERROR
,
49 CHARONSERVICE_PEER_AUTH_ERROR
,
50 CHARONSERVICE_LOOKUP_ERROR
,
51 CHARONSERVICE_UNREACHABLE_ERROR
,
52 CHARONSERVICE_GENERIC_ERROR
,
56 * Public interface of charonservice.
58 * Used to communicate with CharonVpnService via JNI
60 struct charonservice_t
{
63 * Update the status in the Java domain (UI)
65 * @param code status code
66 * @return TRUE on success
68 bool (*update_status
)(charonservice_t
*this, android_vpn_state_t code
);
71 * Install a bypass policy for the given socket using the protect() Method
72 * of the Android VpnService interface
74 * @param fd socket file descriptor
75 * @param family socket protocol family
76 * @return TRUE if operation successful
78 bool (*bypass_socket
)(charonservice_t
*this, int fd
, int family
);
81 * Get a list of trusted certificates via JNI
83 * @return list of DER encoded certificates (as chunk_t*),
86 linked_list_t
*(*get_trusted_certificates
)(charonservice_t
*this);
89 * Get the current vpnservice_builder_t object
91 * @return VpnService.Builder instance
93 vpnservice_builder_t
*(*get_vpnservice_builder
)(charonservice_t
*this);
98 * The single instance of charonservice_t.
100 * Set between JNI calls to initializeCharon() and deinitializeCharon().
102 extern charonservice_t
*charonservice
;
104 #endif /** CHARONSERVICE_H_ @}*/