Skip to content

Commit 81c6909

Browse files
authored
Merge pull request #287 from kbandla/dns_null_flag
unpack null response; add test for it
2 parents afefcc6 + e1b3686 commit 81c6909

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

dpkt/dns.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ def unpack_rdata(self, buf, off):
358358
buf = buf[1 + n:]
359359
elif self.type == DNS_AAAA:
360360
self.ip6 = self.rdata
361+
elif self.type == DNS_NULL:
362+
self.null = self.rdata.encode('hex')
361363
elif self.type == DNS_SRV:
362364
self.priority, self.weight, self.port = struct.unpack('>HHH', self.rdata[:6])
363365
self.srvname, off = unpack_name(buf, off + 6)
@@ -528,16 +530,23 @@ def test_very_long_name():
528530
else:
529531
assert False
530532

533+
def test_null_response():
534+
s = '\x12\xb0\x84\x00\x00\x01\x00\x01\x00\x00\x00\x00\x0bblahblah666\x06pirate\x03sea\x00\x00\n\x00\x01\xc0\x0c\x00\n\x00\x01\x00\x00\x00\x00\x00\tVACKD\x03\xc5\xe9\x01'
535+
my_dns = DNS(s)
536+
assert my_dns.qd[0].name == 'blahblah666.pirate.sea' and \
537+
my_dns.an[0].null == '5641434b4403c5e901'
538+
assert s == str(my_dns)
531539

532540
if __name__ == '__main__':
533541
# Runs all the test associated with this class/file
534542
test_basic()
535543
test_PTR()
536544
test_OPT()
537545
test_pack_name()
538-
test_deprecated_methods()
539-
test_deprecated_method_performance()
540546
test_random_data()
541547
test_circular_pointers()
542548
test_very_long_name()
549+
test_null_response()
550+
test_deprecated_methods()
551+
test_deprecated_method_performance()
543552
print 'Tests Successful...'

0 commit comments

Comments
 (0)