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 """MX-like base classes.""" 17 18 import struct 19 20 import dns.exception 21 import dns.rdata 22 import dns.name 23 import dns.util26 """Base class for rdata that is like an MX record. 27 28 @ivar preference: the preference value 29 @type preference: int 30 @ivar exchange: the exchange name 31 @type exchange: dns.name.Name object""" 32 33 __slots__ = ['preference', 'exchange'] 348436 super(MXBase, self).__init__(rdclass, rdtype) 37 self.preference = preference 38 self.exchange = exchange3941 exchange = self.exchange.choose_relativity(origin, relativize) 42 return '%d %s' % (self.preference, exchange)43 44 @classmethod46 preference = tok.get_uint16() 47 exchange = tok.get_name() 48 exchange = exchange.choose_relativity(origin, relativize) 49 tok.get_eol() 50 return cls(rdclass, rdtype, preference, exchange)5153 pref = struct.pack("!H", self.preference) 54 file.write(pref) 55 self.exchange.to_wire(file, compress, origin)56 60 61 @classmethod63 (preference, ) = struct.unpack('!H', wire[current : current + 2]) 64 current += 2 65 rdlen -= 2 66 (exchange, cused) = dns.name.from_wire(wire[: current + rdlen], 67 current) 68 if cused != rdlen: 69 raise dns.exception.FormError 70 if not origin is None: 71 exchange = exchange.relativize(origin) 72 return cls(rdclass, rdtype, preference, exchange)73 7678 sp = struct.pack("!H", self.preference) 79 op = struct.pack("!H", other.preference) 80 v = dns.util.cmp(sp, op) 81 if v == 0: 82 v = dns.util.cmp(self.exchange, other.exchange) 83 return v86 """Base class for rdata that is like an MX record, but whose name 87 is not compressed when converted to DNS wire format, and whose 88 digestable form is not downcased.""" 89 9295 10294 return self.to_wire(f, None, origin)
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Mar 31 05:21:24 2013 | http://epydoc.sourceforge.net |