• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

README.mdD23-Mar-20244.4 KiB157144

getaddrinfo.tls.topsite.google.pbtxtD23-Mar-20243.3 KiB6260

getaddrinfo.topsite.amazon.pbtxtD23-Mar-20242.1 KiB4544

getaddrinfo.topsite.bing.pbtxtD23-Mar-20242.2 KiB4947

getaddrinfo.topsite.ebay.pbtxtD23-Mar-20242 KiB4543

getaddrinfo.topsite.facebook.pbtxtD23-Mar-20241.3 KiB3533

getaddrinfo.topsite.google.pbtxtD23-Mar-20243.4 KiB8685

getaddrinfo.topsite.netflix.pbtxtD23-Mar-20243.9 KiB7776

getaddrinfo.topsite.reddit.pbtxtD23-Mar-20242.5 KiB5553

getaddrinfo.topsite.wikipedia.pbtxtD23-Mar-20241.7 KiB4139

getaddrinfo.topsite.yahoo.pbtxtD23-Mar-20241.9 KiB4543

getaddrinfo.topsite.youtube.pbtxtD23-Mar-20242.1 KiB4948

gethostbyname.tls.topsite.youtube.pbtxtD23-Mar-20242.5 KiB4847

gethostbyname.topsite.youtube.pbtxtD23-Mar-20241.3 KiB3433

README.md

1
2# Resolv Gold Test
3The "Resolv Gold Test" targets to run automatically in presubmit, as a change
4detector to ensure that the resolver doesn't send the query or parse the
5response unexpectedly.
6
7## Build testing pbtext
8The testing pbtext is built manually so far. Fill expected API parameters to
9'config' and expected answers to 'result' in pbtext. Then, record the
10corresponding DNS query and response packets. Fill the packets with the \x
11formatting into 'query' and 'response' in pbtext. Perhaps have a mechanism
12to generate the pbtxt automatically in the future.
13
14### Using 'ping' utility to be an example for building pbtext
15Here demonstrates how the pbtext is built.
16
171. Enable resolver debug log level to VERBOSE (0)
18```
19$ adb shell service call dnsresolver 10 i32 0
20```
212. Ping a website
22```
23$ adb shell ping www.google.com
24```
253. Get bugreport
26```
27$ adb bugreport
28```
294. Search the log pattern as the follows in bugreport
30```
31# API arguments
32resolv  : logArguments: argv[0]=gethostbyname
33resolv  : logArguments: argv[1]=0
34resolv  : logArguments: argv[2]=www.google.com
35resolv  : logArguments: argv[3]=2
36
37# Query packet
38resolv  : ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29827
39resolv  : ;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
40resolv  : ;; QUERY SECTION:
41resolv  : ;;    www.google.com, type = A, class = IN
42resolv  :
43resolv  : Hex dump:
44resolv  : 7483010000010000000000000377777706676f6f676c6503636f6d0000010001
45
46# Response packet
47resolv  : ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29827
48resolv  : ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
49resolv  : ;; QUERY SECTION:
50resolv  : ;;    www.google.com, type = A, class = IN
51resolv  :
52resolv  : ;; ANSWER SECTION:
53resolv  : ;; www.google.com.        2m19s IN A  172.217.160.100
54resolv  :
55resolv  : Hex dump:
56resolv  : 7483818000010001000000000377777706676f6f676c6503636f6d0000010001
57resolv  : c00c000100010000008b0004acd9a064
58```
59
605. Convert the logging into pbtext. Then, Clear the 'id' which is 0x7483 in
61this example from 'query' and 'response' because 'id' is regenerated per
62session. The follows is result pbtext.
63```
64config {
65    call: CALL_GETHOSTBYNAME
66    hostbyname {
67        host: "www.google.com."
68        family: GT_AF_INET
69    };
70}
71result {
72    return_code: GT_EAI_NO_ERROR
73    addresses: "172.217.160.100"
74}
75packet_mapping {
76    query:    "\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x03\x77\x77\x77"
77              "\x06\x67\x6f\x6f\x67\x6c\x65\x03\x63\x6f\x6d\x00\x00\x01\x00\x01"
78    response: "\x00\x00\x81\x80\x00\x01\x00\x01\x00\x00\x00\x00\x03\x77\x77\x77"
79              "\x06\x67\x6f\x6f\x67\x6c\x65\x03\x63\x6f\x6d\x00\x00\x01\x00\x01"
80              "\xc0\x0c\x00\x01\x00\x01\x00\x00\x00\x8b\x00\x04\xac\xd9\xa0\x64"
81}
82```
83
84## Decode packets in pbtext
85You can invoke the [scapy](https://scapy.net) of python module to extract
86binary packet record in pbtext file. Here are the instructions and example
87for parsing packet.
88
89### Instructions
90Run the following instruction to decode.
91```
92$ python
93>>> from scapy import all as scapy
94>>> scapy.DNS("<paste_hex_string>").show2()
95```
96
97### Example
98Using 'getaddrinfo.topsite.youtube.pbtxt' to be an example here.
99
1001. Find the packet record 'query' or 'response' in .pbtext file.
101```
102query:    "\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x03\x77\x77\x77"
103          "\x07\x79\x6f\x75\x74\x75\x62\x65\x03\x63\x6f\x6d\x00\x00\x1c\x00"
104          "\x01"
105```
1062. Run the following instruction.
107
108Start python
109```
110$ python
111```
112Import scapy
113```
114>>> from scapy import all as scapy
115```
116Assign the binary packet to be decoded into a variable. Beware of using
117backslash '\\' for new line if required
118```
119>>> raw_packet=\
120    "\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x03\x77\x77\x77" \
121    "\x07\x79\x6f\x75\x74\x75\x62\x65\x03\x63\x6f\x6d\x00\x00\x1c\x00" \
122    "\x01"
123```
124Decode packet
125```
126>>> scapy.DNS(raw_packet).show2()
127###[ DNS ]###
128  id        = 0
129  qr        = 0
130  opcode    = QUERY
131  aa        = 0
132  tc        = 0
133  rd        = 1
134  ra        = 0
135  z         = 0
136  ad        = 0
137  cd        = 0
138  rcode     = ok
139  qdcount   = 1
140  ancount   = 0
141  nscount   = 0
142  arcount   = 0
143  \qd        \
144   |###[ DNS Question Record ]###
145   |  qname     = 'www.youtube.com.'
146   |  qtype     = AAAA
147   |  qclass    = IN
148  an        = None
149  ns        = None
150  ar        = None
151```
152
153## Running the tests
154Run the following instruction to test.
155```
156atest resolv_gold_test
157```