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 import dns.util
22
23 -class PX(dns.rdata.Rdata):
24 """PX record.
25
26 @ivar preference: the preference value
27 @type preference: int
28 @ivar map822: the map822 name
29 @type map822: dns.name.Name object
30 @ivar mapx400: the mapx400 name
31 @type mapx400: dns.name.Name object
32 @see: RFC 2163"""
33
34 __slots__ = ['preference', 'map822', 'mapx400']
35
36 - def __init__(self, rdclass, rdtype, preference, map822, mapx400):
41
42 - def to_text(self, origin=None, relativize=True, **kw):
46
47 - def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
55
56 from_text = classmethod(from_text)
57
58 - def to_wire(self, file, compress = None, origin = None):
63
64 - def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
65 (preference, ) = struct.unpack('!H', wire[current : current + 2])
66 current += 2
67 rdlen -= 2
68 (map822, cused) = dns.name.from_wire(wire[: current + rdlen],
69 current)
70 if cused > rdlen:
71 raise dns.exception.FormError
72 current += cused
73 rdlen -= cused
74 if not origin is None:
75 map822 = map822.relativize(origin)
76 (mapx400, cused) = dns.name.from_wire(wire[: current + rdlen],
77 current)
78 if cused != rdlen:
79 raise dns.exception.FormError
80 if not origin is None:
81 mapx400 = mapx400.relativize(origin)
82 return cls(rdclass, rdtype, preference, map822, mapx400)
83
84 from_wire = classmethod(from_wire)
85
89
90 - def _cmp(self, other):
99