1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 import binascii
17
18 import dns.exception
19 import dns.rdata
20 import dns.tokenizer
21
22
23 -class NSAP(dns.rdata.Rdata):
24
25 """NSAP record.
26
27 @ivar address: a NASP
28 @type address: string
29 @see: RFC 1706"""
30
31 __slots__ = ['address']
32
33 - def __init__(self, rdclass, rdtype, address):
36
37 - def to_text(self, origin=None, relativize=True, **kw):
38 return "0x%s" % binascii.hexlify(self.address).decode()
39
40 @classmethod
41 - def from_text(cls, rdclass, rdtype, tok, origin=None, relativize=True):
42 address = tok.get_string()
43 tok.get_eol()
44 if address[0:2] != '0x':
45 raise dns.exception.SyntaxError('string does not start with 0x')
46 address = address[2:].replace('.', '')
47 if len(address) % 2 != 0:
48 raise dns.exception.SyntaxError('hexstring has odd length')
49 address = binascii.unhexlify(address.encode())
50 return cls(rdclass, rdtype, address)
51
52 - def to_wire(self, file, compress=None, origin=None):
54
55 @classmethod
56 - def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin=None):
59