Michal Karpinski | dd9bb4f | 2016-10-12 14:59:26 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.net; |
| 18 | |
| 19 | /** {@hide} */ |
| 20 | oneway interface INetdEventCallback { |
| 21 | |
Ricky Wai | 77518fb | 2017-10-27 14:46:01 +0100 | [diff] [blame] | 22 | // Possible addNetdEventCallback callers. |
dalyk | 99c5029 | 2018-03-08 16:25:48 -0500 | [diff] [blame] | 23 | const int CALLBACK_CALLER_CONNECTIVITY_SERVICE = 0; |
| 24 | const int CALLBACK_CALLER_DEVICE_POLICY = 1; |
| 25 | const int CALLBACK_CALLER_NETWORK_WATCHLIST = 2; |
Ricky Wai | 77518fb | 2017-10-27 14:46:01 +0100 | [diff] [blame] | 26 | |
Michal Karpinski | dd9bb4f | 2016-10-12 14:59:26 +0100 | [diff] [blame] | 27 | /** |
| 28 | * Reports a single DNS lookup function call. |
| 29 | * This method must not block or perform long-running operations. |
| 30 | * |
junyulai | 4c2d2d5 | 2018-10-16 22:58:07 +0800 | [diff] [blame] | 31 | * @param netId the ID of the network the lookup was performed on. |
| 32 | * @param eventType one of the EVENT_* constants in {@link INetdEventListener}. |
| 33 | * @param returnCode the return value of the query, may vary based on {@code eventType}. See |
| 34 | * {@code getaddrinfo()}, {@code gethostbyaddr()} and {@code gethostbyname()} section in |
| 35 | * bionic/libc/include/netdb.h. |
Michal Karpinski | dd9bb4f | 2016-10-12 14:59:26 +0100 | [diff] [blame] | 36 | * @param hostname the name that was looked up. |
| 37 | * @param ipAddresses (possibly a subset of) the IP addresses returned. |
| 38 | * At most {@link #DNS_REPORTED_IP_ADDRESSES_LIMIT} addresses are logged. |
| 39 | * @param ipAddressesCount the number of IP addresses returned. May be different from the length |
| 40 | * of ipAddresses if there were too many addresses to log. |
| 41 | * @param timestamp the timestamp at which the query was reported by netd. |
| 42 | * @param uid the UID of the application that performed the query. |
| 43 | */ |
junyulai | 4c2d2d5 | 2018-10-16 22:58:07 +0800 | [diff] [blame] | 44 | void onDnsEvent(int netId, int eventType, int returnCode, String hostname, |
| 45 | in String[] ipAddresses, int ipAddressesCount, long timestamp, int uid); |
Michal Karpinski | dd9bb4f | 2016-10-12 14:59:26 +0100 | [diff] [blame] | 46 | |
| 47 | /** |
nuccachen | 6e81f2a | 2018-07-30 17:29:45 +0800 | [diff] [blame] | 48 | * Represents adding or removing a NAT64 prefix. |
| 49 | * This method must not block or perform long-running operations. |
| 50 | * |
| 51 | * @param netId the ID of the network the prefix was performed on. |
| 52 | * @param added true if the NAT64 prefix was added, or false if the NAT64 prefix was removed. |
| 53 | * There is only one prefix at a time for each netId. If a prefix is added, it replaces |
| 54 | * the previous-added prefix. |
| 55 | * @param prefixString the detected NAT64 prefix as a string literal. |
| 56 | * @param prefixLength the prefix length associated with this NAT64 prefix. |
| 57 | */ |
| 58 | void onNat64PrefixEvent(int netId, boolean added, @utf8InCpp String prefixString, |
| 59 | int prefixLength); |
| 60 | |
| 61 | /** |
dalyk | 99c5029 | 2018-03-08 16:25:48 -0500 | [diff] [blame] | 62 | * Represents a private DNS validation success or failure. |
| 63 | * This method must not block or perform long-running operations. |
| 64 | * |
| 65 | * @param netId the ID of the network the validation was performed on. |
| 66 | * @param ipAddress the IP address for which validation was performed. |
| 67 | * @param hostname the hostname for which validation was performed. |
| 68 | * @param validated whether or not validation was successful. |
| 69 | */ |
| 70 | void onPrivateDnsValidationEvent(int netId, String ipAddress, String hostname, |
| 71 | boolean validated); |
| 72 | |
| 73 | /** |
Michal Karpinski | dd9bb4f | 2016-10-12 14:59:26 +0100 | [diff] [blame] | 74 | * Reports a single connect library call. |
| 75 | * This method must not block or perform long-running operations. |
| 76 | * |
| 77 | * @param ipAddr destination IP address. |
| 78 | * @param port destination port number. |
| 79 | * @param timestamp the timestamp at which the call was reported by netd. |
| 80 | * @param uid the UID of the application that performed the connection. |
| 81 | */ |
| 82 | void onConnectEvent(String ipAddr, int port, long timestamp, int uid); |
| 83 | } |