1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 import struct
17
18 import dns.exception
19 import dns.rdata
20 import dns.tokenizer
21 from dns._compat import text_type
22
23
24 -class HINFO(dns.rdata.Rdata):
25
26 """HINFO record
27
28 @ivar cpu: the CPU type
29 @type cpu: string
30 @ivar os: the OS type
31 @type os: string
32 @see: RFC 1035"""
33
34 __slots__ = ['cpu', 'os']
35
36 - def __init__(self, rdclass, rdtype, cpu, os):
46
47 - def to_text(self, origin=None, relativize=True, **kw):
48 return '"%s" "%s"' % (dns.rdata._escapify(self.cpu),
49 dns.rdata._escapify(self.os))
50
51 @classmethod
52 - def from_text(cls, rdclass, rdtype, tok, origin=None, relativize=True):
53 cpu = tok.get_string()
54 os = tok.get_string()
55 tok.get_eol()
56 return cls(rdclass, rdtype, cpu, os)
57
58 - def to_wire(self, file, compress=None, origin=None):
59 l = len(self.cpu)
60 assert l < 256
61 file.write(struct.pack('!B', l))
62 file.write(self.cpu)
63 l = len(self.os)
64 assert l < 256
65 file.write(struct.pack('!B', l))
66 file.write(self.os)
67
68 @classmethod
69 - def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin=None):
85