1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 import struct
17
18 import dns.exception
19 import dns.rdata
20 import dns.name
21
22 -class PX(dns.rdata.Rdata):
23 """PX record.
24
25 @ivar preference: the preference value
26 @type preference: int
27 @ivar map822: the map822 name
28 @type map822: dns.name.Name object
29 @ivar mapx400: the mapx400 name
30 @type mapx400: dns.name.Name object
31 @see: RFC 2163"""
32
33 __slots__ = ['preference', 'map822', 'mapx400']
34
35 - def __init__(self, rdclass, rdtype, preference, map822, mapx400):
40
41 - def to_text(self, origin=None, relativize=True, **kw):
45
46 - def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
54
55 from_text = classmethod(from_text)
56
57 - def to_wire(self, file, compress = None, origin = None):
62
63 - def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
64 (preference, ) = struct.unpack('!H', wire[current : current + 2])
65 current += 2
66 rdlen -= 2
67 (map822, cused) = dns.name.from_wire(wire[: current + rdlen],
68 current)
69 if cused > rdlen:
70 raise dns.exception.FormError
71 current += cused
72 rdlen -= cused
73 if not origin is None:
74 map822 = map822.relativize(origin)
75 (mapx400, cused) = dns.name.from_wire(wire[: current + rdlen],
76 current)
77 if cused != rdlen:
78 raise dns.exception.FormError
79 if not origin is None:
80 mapx400 = mapx400.relativize(origin)
81 return cls(rdclass, rdtype, preference, map822, mapx400)
82
83 from_wire = classmethod(from_wire)
84
88