• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2019 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
17syntax = "proto3";
18package android.net;
19
20// Used to indicate which call is invoked to send DNS lookups.
21enum CallType {
22    CALL_GETADDRINFO = 0;
23    CALL_GETHOSTBYNAME = 1;
24    CALL_GETHOSTBYADDR = 2;
25    CALL_GETNAMEINFO = 3;
26    CALL_RES_NSEND = 4;
27}
28
29// Values from bionic/libc/include/sys/socket.h
30enum AddressFamily {
31    option allow_alias = true;  // for AF_ROUTE = AF_NETLINK
32
33    GT_AF_UNSPEC = 0;
34    GT_AF_UNIX = 1;
35    GT_AF_LOCAL = 1;
36    GT_AF_INET = 2;
37    GT_AF_AX25 = 3;
38    GT_AF_IPX = 4;
39    GT_AF_APPLETALK = 5;
40    GT_AF_NETROM = 6;
41    GT_AF_BRIDGE = 7;
42    GT_AF_ATMPVC= 8;
43    GT_AF_X25 = 9;
44    GT_AF_INET6 = 10;
45    GT_AF_ROSE = 11;
46    GT_AF_DECnet = 12;
47    GT_AF_NETBEUI = 13;
48    GT_AF_SECURITY = 14;
49    GT_AF_KEY = 15;
50    GT_AF_NETLINK = 16;
51    GT_AF_ROUTE = 16;  // AF_NETLINK
52    GT_AF_PACKET = 17;
53    GT_AF_ASH = 18;
54    GT_AF_ECONET = 19;
55    GT_AF_ATMSVC = 20;
56    GT_AF_RDS = 21;
57    GT_AF_SNA = 22;
58    GT_AF_IRDA = 23;
59    GT_AF_PPPOX = 24;
60    GT_AF_WANPIPE = 25;
61    GT_AF_LLC = 26;
62    GT_AF_CAN = 29;
63    GT_AF_TIPC = 30;
64    GT_AF_BLUETOOTH = 31;
65    GT_AF_IUCV = 32;
66    GT_AF_RXRPC = 33;
67    GT_AF_ISDN = 34;
68    GT_AF_PHONET = 35;
69    GT_AF_IEEE802154 = 36;
70    GT_AF_CAIF = 37;
71    GT_AF_ALG = 38;
72    GT_AF_NFC = 39;
73    GT_AF_VSOCK = 40;
74    GT_AF_KCM = 41;
75    GT_AF_QIPCRTR = 42;
76    GT_AF_MAX = 43;
77}
78
79// Values from bionic/libc/include/sys/socket.h
80enum SocketType {
81    GT_SOCK_ANY = 0;  // See man getaddrinfo for more detail
82    GT_SOCK_STREAM = 1;
83    GT_SOCK_DGRAM = 2;
84    GT_SOCK_RAW = 3;
85    GT_SOCK_RDM = 4;
86    GT_SOCK_SEQPACKET = 5;
87    GT_SOCK_DCCP = 6;
88    GT_SOCK_PACKET = 10;
89}
90
91// Values from bionic/libc/kernel/uapi/linux/in.h
92enum ProtocolType {
93    GT_IPPROTO_IP = 0;
94    GT_IPPROTO_ICMP = 1;
95    GT_IPPROTO_IGMP = 2;
96    GT_IPPROTO_IPIP = 4;
97    GT_IPPROTO_TCP = 6;
98    GT_IPPROTO_EGP = 8;
99    GT_IPPROTO_PUP = 12;
100    GT_IPPROTO_UDP = 17;
101    GT_IPPROTO_IDP = 22;
102    GT_IPPROTO_TP = 29;
103    GT_IPPROTO_DCCP = 33;
104    GT_IPPROTO_IPV6 = 41;
105    GT_IPPROTO_RSVP = 46;
106    GT_IPPROTO_GRE = 47;
107    GT_IPPROTO_ESP = 50;
108    GT_IPPROTO_AH = 51;
109    GT_IPPROTO_MTP = 92;
110    GT_IPPROTO_BEETPH = 94;
111    GT_IPPROTO_ENCAP = 98;
112    GT_IPPROTO_PIM = 103;
113    GT_IPPROTO_COMP = 108;
114    GT_IPPROTO_SCTP = 132;
115    GT_IPPROTO_UDPLITE = 136;
116    GT_IPPROTO_MPLS = 137;
117    GT_IPPROTO_RAW = 255;
118    GT_IPPROTO_MAX = 256;
119}
120
121// The return value of the DNS resolver for each DNS lookups.
122// Values from bionic/libc/include/netdb.h
123// Values from system/netd/resolv/include/netd_resolv/resolv.h
124enum ReturnCodeType {
125    GT_EAI_NO_ERROR = 0;
126    GT_EAI_ADDRFAMILY = 1;
127    GT_EAI_AGAIN = 2;
128    GT_EAI_BADFLAGS = 3;
129    GT_EAI_FAIL = 4;
130    GT_EAI_FAMILY = 5;
131    GT_EAI_MEMORY = 6;
132    GT_EAI_NODATA = 7;
133    GT_EAI_NONAME = 8;
134    GT_EAI_SERVICE = 9;
135    GT_EAI_SOCKTYPE = 10;
136    GT_EAI_SYSTEM = 11;
137    GT_EAI_BADHINTS = 12;
138    GT_EAI_PROTOCOL = 13;
139    GT_EAI_OVERFLOW = 14;
140    GT_RESOLV_TIMEOUT = 255;
141    GT_EAI_MAX = 256;
142}
143
144// Describes the test configuration and expected result for gold test.
145// The unit test files a DNS query by the predefined |config|. Expect that the resolver sends the
146// query packet as the predefined packet in |packet_mapping.query|. When the DNS responser receives
147// the query packet, it returns the corresponding response packet from |packet_mapping.response|.
148// Finally, the unit test checks the return values if they are the same as |result|. Currently,
149// support getaddrinfo only.
150// TODO: Support gethostbyname, gethostbyaddr, and getnameinfo.
151message GoldTest {
152    // The configuration of various DNS query calls.
153    message Config {
154        // The arguments used to send a DNS query by call type CALL_GETADDRINFO.
155        message AddrInfo {
156            string host = 1;
157            AddressFamily family = 2;
158            SocketType socktype = 3;
159            ProtocolType protocol = 4;
160            int32 ai_flags = 5;
161        }
162
163        // The arguments used to send a DNS query by call type CALL_GETHOSTBYNAME.
164        message HostByName {
165            string host = 1;
166            AddressFamily family = 2;
167        }
168
169        // The call is used to send DNS lookups.
170        CallType call = 1;
171
172        // The arguments are used by the call.
173        oneof Arg {
174            // The arguments of call type CALL_GETADDRINFO.
175            AddrInfo addrinfo = 2;
176            HostByName hostbyname = 3;
177        }
178    };
179
180    // The result is expected in DNS lookups.
181    message Result {
182        ReturnCodeType return_code = 1;
183        repeated string addresses = 2;
184    };
185
186    // Describes how the DNS responser handles and responses the DNS lookup packets.
187    message PacketMapping {
188      bytes query = 1;
189      bytes response = 2;
190    }
191
192    // Configs used to send a DNS query via a DNS query API.
193    Config config = 1;
194
195    // Expected return values from DNS query API.
196    Result result = 2;
197
198    // Used to build the packet mapping (query, response) in DNS responser. See also
199    // addMappingBinaryPacket() in
200    // packages/modules/DnsResolver/tests/dns_responder/dns_responder.cpp.
201    repeated PacketMapping packet_mapping = 3;
202}
203