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.name24 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'] 368838 super(PX, self).__init__(rdclass, rdtype) 39 self.preference = preference 40 self.map822 = map822 41 self.mapx400 = mapx4004244 map822 = self.map822.choose_relativity(origin, relativize) 45 mapx400 = self.mapx400.choose_relativity(origin, relativize) 46 return '%d %s %s' % (self.preference, map822, mapx400)47 48 @classmethod50 preference = tok.get_uint16() 51 map822 = tok.get_name() 52 map822 = map822.choose_relativity(origin, relativize) 53 mapx400 = tok.get_name(None) 54 mapx400 = mapx400.choose_relativity(origin, relativize) 55 tok.get_eol() 56 return cls(rdclass, rdtype, preference, map822, mapx400)5759 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 @classmethod66 (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)8486 self.map822 = self.map822.choose_relativity(origin, relativize) 87 self.mapx400 = self.mapx400.choose_relativity(origin, relativize)
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Sep 30 08:16:44 2016 | http://epydoc.sourceforge.net |