From aa2a8142196156464d60b45bcef0765a66b46f78 Mon Sep 17 00:00:00 2001 From: JINMEI Tatuya Date: Fri, 9 Apr 2010 22:51:51 +0000 Subject: [PATCH] supported a simple name with possible compression git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1701 e5f2f494-b856-4b98-b285-d166d9295462 --- src/lib/dns/tests/testdata/gen-wiredata.py.in | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/lib/dns/tests/testdata/gen-wiredata.py.in b/src/lib/dns/tests/testdata/gen-wiredata.py.in index b1c860c9d6..2969692bd9 100755 --- a/src/lib/dns/tests/testdata/gen-wiredata.py.in +++ b/src/lib/dns/tests/testdata/gen-wiredata.py.in @@ -60,15 +60,16 @@ def code_totext(code, dict): return dict[code] + '(' + str(code) + ')' return str(code) -def encode_name(name): +def encode_name(name, absolute = True): # make sure the name is dot-terminated. duplicate dots will be ignored # below. name += '.' labels = name.split('.') wire = '' for l in labels: - wire += '%02x' % len(l) - wire += ''.join(['%02x' % ord(ch) for ch in l]) + if absolute or len(l) > 0: + wire += '%02x' % len(l) + wire += ''.join(['%02x' % ord(ch) for ch in l]) if len(l) == 0: break return wire @@ -103,6 +104,21 @@ def print_header(f, input_file): ### ''') +class Name: + name = 'example.com' + pointer = -1 # no compression by default + def dump(self, f): + name_wire = encode_name(self.name, + True if self.pointer == -1 else False) + f.write('\n# DNS Name: %s' % self.name) + if self.pointer >= 0: + f.write(' + compression pointer: %d' % self.pointer) + f.write('\n') + f.write('%s' % name_wire) + if self.pointer >= 0: + f.write(' %04x' % (0xc000 | self.pointer)) + f.write('\n') + class DNSHeader: id = 0x1035 (qr, aa, tc, rd, ra, ad, cd) = 0, 0, 0, 0, 0, 0, 0 @@ -316,7 +332,8 @@ class RRSIG: f.write('%04x %s %s\n' % (self.tag, name_wire, sig_wire)) def get_config_param(section): - config_param = {'header' : (DNSHeader, header_xtables), + config_param = {'name' : (Name, {}), + 'header' : (DNSHeader, header_xtables), 'question' : (DNSQuestion, question_xtables), 'edns' : (EDNS, {}), 'soa' : (SOA, {}), 'txt' : (TXT, {}), 'rrsig' : (RRSIG, {}), 'nsec' : (NSEC, {})}