Unable to start a driver from Android App


  1. arjun.laxman

    arjun.laxman Member

    Hi,
    I am writing an Android Application for the first time. I need to start a Tun driver from Android App. I have two shared libraries created. One is JNI shared library and the other is the cross-compiled library which actually does creating of a tunneling module,assigning IP Address, starting the tun driver and configuring by setting the IP address and setting up a route for it.
    After getting server IP address and server port through App, I call JNI function to start tun module. The JNI library in turn calls the function in the cross-compiled library which actually does the job.
    But the issue is the permission to start the device files. I faced issue while creating a socket, so I set the permission android.permission.INTERNET in AndroidManifest.xml. I was able to create socket and DHCP too worked. Now, I am facing an issue to start the Tun driver. I am able to open the device file "/dev/tun" but unable to set the properties to it by calling ioctl(fd, TUNSETIFF, &ifr) due to Permission problems.
    If I make the cross-compiled library an executable and start it on ADB shell prompt of the mobile phone using SU permissions, it works perfectly fine. But through Android App, I am not able to do so due to some permission issue. I have tried giving all sorts of permissions in AndroidManifest.xml file, but no progress. I am stuck with this problem for days and any help will be greatly appreciated.

    Thanks in advance.

    Regards,
    Arjun

    Advertisement
  2. arjun.laxman

    arjun.laxman Member

    Following is the log:

    I/PowerManagerService( 2437): Ulight 3->7|0
    V/WindowManager( 2437): Dsptch > Window{4814cc18 com.example.Tunneling/com.examp
    le.Tunneling.Tun_utils paused=false}
    V/WindowManager( 2437): Dsptch > Window{4814cc18 com.example.Tunneling/com.examp
    le.Tunneling.Tun_utils paused=false}
    V/InputDevice( 2437): ID[0]=0(0) Up(1=>0)
    E/Tunneling( 6732): Submit button clicked
    E/Tunneling( 6732): Save button clicked
    D/dalvikvm( 6732): Trying to load lib /data/data/com.example.Tunneling/lib/libNT
    Client.so 0x47b49bc8
    D/dalvikvm( 6732): Added shared lib /data/data/com.example.Tunneling/lib/libNTCl
    ient.so 0x47b49bc8
    D/dalvikvm( 6732): No JNI_OnLoad found in /data/data/com.example.Tunneling/lib/l
    ibNTClient.so 0x47b49bc8, skipping init
    D/dalvikvm( 6732): Trying to load lib /data/data/com.example.Tunneling/lib/libTu
    nneling.so 0x47b49bc8
    D/dalvikvm( 6732): Added shared lib /data/data/com.example.Tunneling/lib/libTunn
    eling.so 0x47b49bc8
    D/dalvikvm( 6732): No JNI_OnLoad found in /data/data/com.example.Tunneling/lib/l
    ibTunneling.so 0x47b49bc8, skipping init
    E/Tunneling( 6732): Start_tun()
    E/Tunneling( 6732): Server address is 168.219.193.188
    E/Tunneling( 6732): Server port is 5000
    E/Tunneling( 6732): Read per once is 1500
    E/Tunneling( 6732): Entering Start_Tunneling_module()
    E/Tunneling( 6732): After Setting the initial DebugLevel and Format
    E/Tunneling( 6732): Got the Server Ip Address is 168.219.193.188
    E/Tunneling( 6732): Trying to Start up the Tunneling Client
    E/Tunneling( 6732): start remote server with [5000] port
    E/Tunneling( 6732): Network Initialize success
    E/Tunneling( 6732): sock value is 37,psock value is37
    E/Tunneling( 6732): SOCKET::Open() created successfully, the m_hSock is 37, ret is 0
    E/Tunneling( 6732): DHCP:: Source Address and Port is (null):5000
    E/Tunneling( 6732): REMOTE MESSAGE IN :[168.219.193.188(5000)] - 44 Byte
    E/Tunneling( 6732): STUN RESPONSE PACKET ==>> now processing
    E/Tunneling( 6732): GET [DHCP_RESPONSE]--
    E/Tunneling( 6732): GetDHCP =>
    E/Tunneling( 6732): <=GetDHCP
    E/Tunneling( 6732): GET [DHCP_RESPONSE]++
    E/Tunneling( 6732):
    E/Tunneling( 6732): Address Allocation Success
    E/Tunneling( 6732): Trying to start the Tun Driver
    E/Tunneling( 6732): Cannot Set Driver OTUNSETIFF
    E/Tunneling( 6732): Cannot Open tun driver

Share This Page