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