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

Source Code for Module dns.rdtypes.IN.PX

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