Implement JNI calls on VpnService class for Android native app

  • Status Closed
  • Budget $15 - $25 USD / hour
  • Total Bids 10

Project Description

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_is_available(void);

int tun_set_routes(in_addr_t gateway, in_addr_t server);

int tun_restore_routes(void);

int tun_set_dns(in_addr_t dns_server);

int tun_restore_dns(void);

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.

Thank you.

Get free quotes for a project like this
Skills Required

Looking to make some money?

  • Set your budget and the timeframe
  • Outline your proposal
  • Get paid for your work

Hire Freelancers who also bid on this project

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online