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.tokenizer 23 from dns._compat import text_type27 28 """HINFO record 29 30 @ivar cpu: the CPU type 31 @type cpu: string 32 @ivar os: the OS type 33 @type os: string 34 @see: RFC 1035""" 35 36 __slots__ = ['cpu', 'os'] 378739 super(HINFO, self).__init__(rdclass, rdtype) 40 if isinstance(cpu, text_type): 41 self.cpu = cpu.encode() 42 else: 43 self.cpu = cpu 44 if isinstance(os, text_type): 45 self.os = os.encode() 46 else: 47 self.os = os48 52 53 @classmethod55 cpu = tok.get_string() 56 os = tok.get_string() 57 tok.get_eol() 58 return cls(rdclass, rdtype, cpu, os)5961 l = len(self.cpu) 62 assert l < 256 63 file.write(struct.pack('!B', l)) 64 file.write(self.cpu) 65 l = len(self.os) 66 assert l < 256 67 file.write(struct.pack('!B', l)) 68 file.write(self.os)69 70 @classmethod72 l = wire[current] 73 current += 1 74 rdlen -= 1 75 if l > rdlen: 76 raise dns.exception.FormError 77 cpu = wire[current:current + l].unwrap() 78 current += l 79 rdlen -= l 80 l = wire[current] 81 current += 1 82 rdlen -= 1 83 if l != rdlen: 84 raise dns.exception.FormError 85 os = wire[current: current + l].unwrap() 86 return cls(rdclass, rdtype, cpu, os)
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Dec 8 10:59:56 2018 | http://epydoc.sourceforge.net |