From 4729949b505529ac7e3e006841f8b395125300c5 Mon Sep 17 00:00:00 2001 From: Remi NGUYEN VAN Date: Tue, 23 Mar 2021 00:54:35 +0000 Subject: [PATCH] Add NDK API for getprocdns, setprocdns The API allows callers to control the default network that is used for DNS hostname resolution. Test: atest CtsNetTestCases Tests in change I00143cafcd3eb1d71e8d5c7ea9c839a99dc6f4ce Bug: 171540887 Change-Id: I70d8113ae49cd1e0910a6dbc5929b6a157c44f42 --- include/android/multinetwork.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/android/multinetwork.h b/include/android/multinetwork.h index fa7759393c..509ee0e49b 100644 --- a/include/android/multinetwork.h +++ b/include/android/multinetwork.h @@ -102,6 +102,28 @@ int android_setprocnetwork(net_handle_t network) __INTRODUCED_IN(23); */ int android_getprocnetwork(net_handle_t *network) __INTRODUCED_IN(31); +/** + * Binds domain name resolutions performed by this process to |network|. + * android_setprocnetwork takes precedence over this setting. + * + * To clear a previous process binding, invoke with NETWORK_UNSPECIFIED. + * On success 0 is returned. On error -1 is returned, and errno is set. + * + * Available since API level 31. + */ +int android_setprocdns(net_handle_t network) __INTRODUCED_IN(31); + +/** + * Gets the |network| to which domain name resolutions are bound on the + * current process. + * + * Returns 0 on success, or -1 setting errno to EINVAL if a null pointer is + * passed in. + * + * Available since API level 31. + */ +int android_getprocdns(net_handle_t *network) __INTRODUCED_IN(31); + /** * Perform hostname resolution via the DNS servers associated with |network|.