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