Add jni method for DnsResolver

Test: built, flashed, booted
      atest DnsResolverTest

Change-Id: Iff730ec918f4db1ba0216f90a12550fe26e271d0
This commit is contained in:
Luke Huang
2019-01-04 19:46:47 +08:00
parent 89e53d81ce
commit 92ae35ec9f
2 changed files with 116 additions and 0 deletions

View File

@@ -34,6 +34,8 @@ import java.util.Collection;
import java.util.Locale;
import java.util.TreeSet;
import android.system.ErrnoException;
/**
* Native methods for managing network interfaces.
*
@@ -132,6 +134,32 @@ public class NetworkUtils {
*/
public native static boolean queryUserAccess(int uid, int netId);
/**
* DNS resolver series jni method.
* Issue the query {@code msg} on the network designated by {@code netId}.
* {@code flags} is an additional config to control actual querying behavior.
* @return a file descriptor to watch for read events
*/
public static native FileDescriptor resNetworkSend(
int netId, byte[] msg, int msglen, int flags) throws ErrnoException;
/**
* DNS resolver series jni method.
* Look up the {@code nsClass} {@code nsType} Resource Record (RR) associated
* with Domain Name {@code dname} on the network designated by {@code netId}.
* {@code flags} is an additional config to control actual querying behavior.
* @return a file descriptor to watch for read events
*/
public static native FileDescriptor resNetworkQuery(
int netId, String dname, int nsClass, int nsType, int flags) throws ErrnoException;
/**
* DNS resolver series jni method.
* Read a result for the query associated with the {@code fd}.
* @return a byte array containing blob answer
*/
public static native byte[] resNetworkResult(FileDescriptor fd) throws ErrnoException;
/**
* Add an entry into the ARP cache.
*/