Our daemon (vpn client) is compiled on Android NDK successfully, but there are issues to use tun driver on non-rooted devices and launch our app as service. We want to use VpnService class, which is provided on Android from version 4.0.
We have a tunnel library written on C. This is a library which handles all tunnel device related stuff (creating tunnel device, setting ip/routes/dns server for tunnel device, sending packets to tunnel device which are received by vpn library, reading packets from tunnel device which should be sent by vpn library to server). Here is part of libtun/libtun.h header:
int tun_open_withip(const char *tun_dev, const char *ip, unsigned netbits,
int mtu, in_addr_t srv_ip);
void tun_close(int tun_fd);
int tun_write(int tun_fd, char *buf, size_t len);
ssize_t tun_read(int tun_fd, char *buf, size_t len);
int tun_set_routes(in_addr_t gateway, in_addr_t server);
int tun_set_dns(in_addr_t dns_server);
These functions are called by our daemon ran on Android when they need to perform some of these actions. We have Linux (desktop, Windows and Mac OS X) versions. Your task is to analyze what they are doing and provide Android version of these functions. You should use Android VPNService API for this. Using Linux native calls is not acceptable, because they are requiring rooted device, but most of users do not root their device.
VPNService API is only available from Java code, but not from NDK. So you should write some java code and then call it from these C functions. If some portion of code could be both written in Java or in C, please write it in C. Java should be used only when it is not possible to use C for something.
Android can kill any process at any time if it is not running as service. Our daemon should run this way. So, second task is to write code which starts daemon as service using android Services API.
We'd like to use #ifdef ANDROID in libtun and place android versions of the functions to separate file.
8 freelancers are bidding on average $20/hour for this job
15+yeas devleoper expert in ndk and android and for our first time corporation no need for previously pay and you can make you first pay after first time we update you