Home | Trees | Indices | Help |
|
---|
|
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.name26 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'] 389040 super(PX, self).__init__(rdclass, rdtype) 41 self.preference = preference 42 self.map822 = map822 43 self.mapx400 = mapx4004446 map822 = self.map822.choose_relativity(origin, relativize) 47 mapx400 = self.mapx400.choose_relativity(origin, relativize) 48 return '%d %s %s' % (self.preference, map822, mapx400)49 50 @classmethod52 preference = tok.get_uint16() 53 map822 = tok.get_name() 54 map822 = map822.choose_relativity(origin, relativize) 55 mapx400 = tok.get_name(None) 56 mapx400 = mapx400.choose_relativity(origin, relativize) 57 tok.get_eol() 58 return cls(rdclass, rdtype, preference, map822, mapx400)5961 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 @classmethod68 (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)8688 self.map822 = self.map822.choose_relativity(origin, relativize) 89 self.mapx400 = self.mapx400.choose_relativity(origin, relativize)
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Dec 8 10:59:57 2018 | http://epydoc.sourceforge.net |