1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 import dns.exception
17 import dns.rdata
18 import dns.tokenizer
19 import dns.util
20
21 -class HINFO(dns.rdata.Rdata):
22 """HINFO record
23
24 @ivar cpu: the CPU type
25 @type cpu: string
26 @ivar os: the OS type
27 @type os: string
28 @see: RFC 1035"""
29
30 __slots__ = ['cpu', 'os']
31
32 - def __init__(self, rdclass, rdtype, cpu, os):
36
37 - def to_text(self, origin=None, relativize=True, **kw):
38 return '"%s" "%s"' % (dns.rdata._escapify(self.cpu),
39 dns.rdata._escapify(self.os))
40
41 - def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
42 cpu = tok.get_string()
43 os = tok.get_string()
44 tok.get_eol()
45 return cls(rdclass, rdtype, cpu, os)
46
47 from_text = classmethod(from_text)
48
49 - def to_wire(self, file, compress = None, origin = None):
50 l = len(self.cpu)
51 assert l < 256
52 dns.util.write_uint8(file, l)
53 file.write(self.cpu.encode('latin_1'))
54 l = len(self.os)
55 assert l < 256
56 dns.util.write_uint8(file, l)
57 file.write(self.os.encode('latin_1'))
58
59 - def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
60 l = wire[current]
61 current += 1
62 rdlen -= 1
63 if l > rdlen:
64 raise dns.exception.FormError
65 cpu = wire[current : current + l].decode('latin_1')
66 current += l
67 rdlen -= l
68 l = wire[current]
69 current += 1
70 rdlen -= 1
71 if l != rdlen:
72 raise dns.exception.FormError
73 os = wire[current : current + l].decode('latin_1')
74 return cls(rdclass, rdtype, cpu, os)
75
76 from_wire = classmethod(from_wire)
77
78 - def _cmp(self, other):
83