}
}
+METHOD(charonservice_t, bypass_socket, bool,
+ private_charonservice_t *this, int fd, int family)
+{
+ JNIEnv *env;
+ jmethodID method_id;
+
+ androidjni_attach_thread(&env);
+
+ method_id = (*env)->GetMethodID(env, android_charonvpnservice_class,
+ "protect", "(I)Z");
+ if (!method_id)
+ {
+ goto failed;
+ }
+ if (!(*env)->CallBooleanMethod(env, this->vpn_service, method_id, fd))
+ {
+ DBG1(DBG_CFG, "VpnService.protect() failed");
+ goto failed;
+ }
+ androidjni_detach_thread();
+ return TRUE;
+
+failed:
+ androidjni_exception_occurred(env);
+ androidjni_detach_thread();
+ return FALSE;
+}
+
/**
* Initialize the charonservice object
*/
INIT(this,
.public = {
+ .bypass_socket = _bypass_socket,
},
.vpn_service = (*env)->NewGlobalRef(env, service),
);
#ifndef CHARONSERVICE_H_
#define CHARONSERVICE_H_
+#include <library.h>
+
typedef struct charonservice_t charonservice_t;
/**
*/
struct charonservice_t {
+ /**
+ * Install a bypass policy for the given socket using the protect() Method
+ * of the Android VpnService interface
+ *
+ * @param fd socket file descriptor
+ * @param family socket protocol family
+ * @return TRUE if operation successful
+ */
+ bool (*bypass_socket)(charonservice_t *this, int fd, int family);
+
};
/**
*/
#include "android_ipsec.h"
+#include "../charonservice.h"
#include <debug.h>
#include <library.h>
METHOD(kernel_ipsec_t, bypass_socket, bool,
private_kernel_android_ipsec_t *this, int fd, int family)
{
- return NOT_SUPPORTED;
+ return charonservice->bypass_socket(charonservice, fd, family);
}
METHOD(kernel_ipsec_t, enable_udp_decap, bool,