@@ -186,6 +186,50 @@ public function testParseResponseWithCnameAndOffsetPointers()
186186 $ this ->assertSame ('googlemail.l.google.com ' , $ response ->answers [0 ]->data );
187187 }
188188
189+ public function testParseAAAAResponse ()
190+ {
191+ $ data = "" ;
192+ $ data .= "cd 72 81 80 00 01 00 01 00 00 00 00 06 " ; // header
193+ $ data .= "67 6f 6f 67 6c 65 03 63 6f 6d 00 " ; // question: google.com
194+ $ data .= "00 1c 00 01 " ; // question: type AAAA, class IN
195+ $ data .= "c0 0c " ; // answer: offset pointer to google.com
196+ $ data .= "00 1c 00 01 " ; // answer: type AAAA, class IN
197+ $ data .= "00 00 01 2b " ; // answer: ttl 299
198+ $ data .= "00 10 " ; // answer: rdlength 16
199+ $ data .= "2a 00 14 50 40 09 08 09 00 00 00 00 00 00 20 0e " ; // answer: 2a00:1450:4009:809::200e
200+
201+ $ data = $ this ->convertTcpDumpToBinary ($ data );
202+
203+ $ response = $ this ->parser ->parseMessage ($ data );
204+
205+ $ header = $ response ->header ;
206+ $ this ->assertSame (0xcd72 , $ header ->get ('id ' ));
207+ $ this ->assertSame (1 , $ header ->get ('qdCount ' ));
208+ $ this ->assertSame (1 , $ header ->get ('anCount ' ));
209+ $ this ->assertSame (0 , $ header ->get ('nsCount ' ));
210+ $ this ->assertSame (0 , $ header ->get ('arCount ' ));
211+ $ this ->assertSame (1 , $ header ->get ('qr ' ));
212+ $ this ->assertSame (Message::OPCODE_QUERY , $ header ->get ('opcode ' ));
213+ $ this ->assertSame (0 , $ header ->get ('aa ' ));
214+ $ this ->assertSame (0 , $ header ->get ('tc ' ));
215+ $ this ->assertSame (1 , $ header ->get ('rd ' ));
216+ $ this ->assertSame (1 , $ header ->get ('ra ' ));
217+ $ this ->assertSame (0 , $ header ->get ('z ' ));
218+ $ this ->assertSame (Message::RCODE_OK , $ header ->get ('rcode ' ));
219+
220+ $ this ->assertCount (1 , $ response ->questions );
221+ $ this ->assertSame ('google.com ' , $ response ->questions [0 ]['name ' ]);
222+ $ this ->assertSame (Message::TYPE_AAAA , $ response ->questions [0 ]['type ' ]);
223+ $ this ->assertSame (Message::CLASS_IN , $ response ->questions [0 ]['class ' ]);
224+
225+ $ this ->assertCount (1 , $ response ->answers );
226+ $ this ->assertSame ('google.com ' , $ response ->answers [0 ]->name );
227+ $ this ->assertSame (Message::TYPE_AAAA , $ response ->answers [0 ]->type );
228+ $ this ->assertSame (Message::CLASS_IN , $ response ->answers [0 ]->class );
229+ $ this ->assertSame (299 , $ response ->answers [0 ]->ttl );
230+ $ this ->assertSame ('2a00:1450:4009:809::200e ' , $ response ->answers [0 ]->data );
231+ }
232+
189233 public function testParseResponseWithTwoAnswers ()
190234 {
191235 $ data = "" ;
0 commit comments