Package dns :: Package rdtypes :: Package IN :: Module PX
[hide private]
[frames] | no frames]

Source Code for Module dns.rdtypes.IN.PX

 1  # Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license 
 2   
 3  # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc. 
 4  # 
 5  # Permission to use, copy, modify, and distribute this software and its 
 6  # documentation for any purpose with or without fee is hereby granted, 
 7  # provided that the above copyright notice and this permission notice 
 8  # appear in all copies. 
 9  # 
10  # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES 
11  # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 
12  # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR 
13  # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 
14  # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
15  # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 
16  # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 
17   
18  import struct 
19   
20  import dns.exception 
21  import dns.rdata 
22  import dns.name 
23 24 25 -class PX(dns.rdata.Rdata):
26 27 """PX record. 28 29 @ivar preference: the preference value 30 @type preference: int 31 @ivar map822: the map822 name 32 @type map822: dns.name.Name object 33 @ivar mapx400: the mapx400 name 34 @type mapx400: dns.name.Name object 35 @see: RFC 2163""" 36 37 __slots__ = ['preference', 'map822', 'mapx400'] 38
39 - def __init__(self, rdclass, rdtype, preference, map822, mapx400):
40 super(PX, self).__init__(rdclass, rdtype) 41 self.preference = preference 42 self.map822 = map822 43 self.mapx400 = mapx400
44
45 - def to_text(self, origin=None, relativize=True, **kw):
49 50 @classmethod
51 - def from_text(cls, rdclass, rdtype, tok, origin=None, relativize=True):
59
60 - def to_wire(self, file, compress=None, origin=None):
61 pref = struct.pack("!H", self.preference) 62 file.write(pref) 63 self.map822.to_wire(file, None, origin) 64 self.mapx400.to_wire(file, None, origin)
65 66 @classmethod
67 - def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin=None):
68 (preference, ) = struct.unpack('!H', wire[current: current + 2]) 69 current += 2 70 rdlen -= 2 71 (map822, cused) = dns.name.from_wire(wire[: current + rdlen], 72 current) 73 if cused > rdlen: 74 raise dns.exception.FormError 75 current += cused 76 rdlen -= cused 77 if origin is not None: 78 map822 = map822.relativize(origin) 79 (mapx400, cused) = dns.name.from_wire(wire[: current + rdlen], 80 current) 81 if cused != rdlen: 82 raise dns.exception.FormError 83 if origin is not None: 84 mapx400 = mapx400.relativize(origin) 85 return cls(rdclass, rdtype, preference, map822, mapx400)
86
87 - def choose_relativity(self, origin=None, relativize=True):
90