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.metrics;
18 
19 /**
20  * Logs netd events.
21  *
22  * {@hide}
23  */
24 oneway interface INetdEventListener {
25     const int EVENT_GETADDRINFO = 1;
26     const int EVENT_GETHOSTBYNAME = 2;
27 
28     const int REPORTING_LEVEL_NONE = 0;
29     const int REPORTING_LEVEL_METRICS = 1;
30     const int REPORTING_LEVEL_FULL = 2;
31 
32     // Maximum number of IP addresses logged for DNS lookups before we truncate the full list.
33     const int DNS_REPORTED_IP_ADDRESSES_LIMIT = 10;
34 
35     /**
36      * Logs a DNS lookup function call (getaddrinfo and gethostbyname).
37      *
38      * @param netId the ID of the network the lookup was performed on.
39      * @param eventType one of the EVENT_* constants in this interface.
40      * @param returnCode the return value of the function call.
41      * @param latencyMs the latency of the function call.
42      * @param hostname the name that was looked up.
43      * @param ipAddresses (possibly a subset of) the IP addresses returned.
44      *        At most {@link #DNS_REPORTED_IP_ADDRESSES_LIMIT} addresses are logged.
45      * @param ipAddressesCount the number of IP addresses returned. May be different from the length
46      *        of ipAddresses if there were too many addresses to log.
47      * @param uid the UID of the application that performed the query.
48      */
onDnsEvent(int netId, int eventType, int returnCode, int latencyMs, String hostname, in String[] ipAddresses, int ipAddressesCount, int uid)49     void onDnsEvent(int netId, int eventType, int returnCode, int latencyMs, String hostname,
50             in String[] ipAddresses, int ipAddressesCount, int uid);
51 
52     /**
53      * Logs a single connect library call.
54      *
55      * @param netId the ID of the network the connect was performed on.
56      * @param error 0 if the connect call succeeded, otherwise errno if it failed.
57      * @param latencyMs the latency of the connect call.
58      * @param ipAddr destination IP address.
59      * @param port destination port number.
60      * @param uid the UID of the application that performed the connection.
61      */
onConnectEvent(int netId, int error, int latencyMs, String ipAddr, int port, int uid)62     void onConnectEvent(int netId, int error, int latencyMs, String ipAddr, int port, int uid);
63 }
64