package net.hivetechnology.o20010_06.vpn

import android.net.VpnService

object NativeBridge {
    init {
        System.loadLibrary("o20010_06")
    }

    external fun create(
        protector: VpnService,
        supernode: String,
        community: String,
        key: String,
        address: String,
        peerAddress: String,
        prefixLength: Int,
        mtu: Int,
        transport: Int,
    ): Long
    external fun start(handle: Long): Int
    external fun state(handle: Long): Int
    external fun peerPath(handle: Long): Int
    external fun resolvePeer(handle: Long, peerAddress: String, timeoutMs: Int): Int
    external fun send(handle: Long, packet: ByteArray, length: Int): Int
    external fun receive(handle: Long, capacity: Int, timeoutMs: Int): ByteArray?
    external fun stop(handle: Long)
    external fun destroy(handle: Long)
    external fun version(): String

    const val STATE_CONNECTING = 1
    const val STATE_CONNECTED = 2
    const val STATE_STOPPED = 4
    const val STATE_FAILED = 5

    const val TRANSPORT_UDP_P2P = 0
    const val TRANSPORT_UDP_RELAY = 1
    const val TRANSPORT_TCP_RELAY = 2

    const val PEER_PATH_UNKNOWN = 0
    const val PEER_PATH_P2P = 1
    const val PEER_PATH_RELAY = 2
}
