Home | Trees | Indices | Help |
|
---|
|
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 2123 """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'] 349836 super(PX, self).__init__(rdclass, rdtype) 37 self.preference = preference 38 self.map822 = map822 39 self.mapx400 = mapx4004042 map822 = self.map822.choose_relativity(origin, relativize) 43 mapx400 = self.mapx400.choose_relativity(origin, relativize) 44 return '%d %s %s' % (self.preference, map822, mapx400)4547 preference = tok.get_uint16() 48 map822 = tok.get_name() 49 map822 = map822.choose_relativity(origin, relativize) 50 mapx400 = tok.get_name(None) 51 mapx400 = mapx400.choose_relativity(origin, relativize) 52 tok.get_eol() 53 return cls(rdclass, rdtype, preference, map822, mapx400)54 55 from_text = classmethod(from_text) 5658 pref = struct.pack("!H", self.preference) 59 file.write(pref) 60 self.map822.to_wire(file, None, origin) 61 self.mapx400.to_wire(file, None, origin)6264 (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) 8486 self.map822 = self.map822.choose_relativity(origin, relativize) 87 self.mapx400 = self.mapx400.choose_relativity(origin, relativize)8890 sp = struct.pack("!H", self.preference) 91 op = struct.pack("!H", other.preference) 92 v = cmp(sp, op) 93 if v == 0: 94 v = cmp(self.map822, other.map822) 95 if v == 0: 96 v = cmp(self.mapx400, other.mapx400) 97 return v
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Mar 22 09:18:00 2013 | http://epydoc.sourceforge.net |