1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
// Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)
package org.xbill.DNS;
import java.io.*;
/**
* Host Information - describes the CPU and OS of a host
*
* @author Brian Wellington
*/
public class HINFORecord extends Record {
private static final long serialVersionUID = -4732870630947452112L;
private byte [] cpu, os;
HINFORecord() {}
Record
getObject() {
return new HINFORecord();
}
/**
* Creates an HINFO Record from the given data
* @param cpu A string describing the host's CPU
* @param os A string describing the host's OS
* @throws IllegalArgumentException One of the strings has invalid escapes
*/
public
HINFORecord(Name name, int dclass, long ttl, String cpu, String os) {
super(name, Type.HINFO, dclass, ttl);
try {
this.cpu = byteArrayFromString(cpu);
this.os = byteArrayFromString(os);
}
catch (TextParseException e) {
throw new IllegalArgumentException(e.getMessage());
}
}
void
rrFromWire(DNSInput in) throws IOException {
cpu = in.readCountedString();
os = in.readCountedString();
}
void
rdataFromString(Tokenizer st, Name origin) throws IOException {
try {
cpu = byteArrayFromString(st.getString());
os = byteArrayFromString(st.getString());
}
catch (TextParseException e) {
throw st.exception(e.getMessage());
}
}
/**
* Returns the host's CPU
*/
public String
getCPU() {
return byteArrayToString(cpu, false);
}
/**
* Returns the host's OS
*/
public String
getOS() {
return byteArrayToString(os, false);
}
void
rrToWire(DNSOutput out, Compression c, boolean canonical) {
out.writeCountedString(cpu);
out.writeCountedString(os);
}
/**
* Converts to a string
*/
String
rrToString() {
StringBuffer sb = new StringBuffer();
sb.append(byteArrayToString(cpu, true));
sb.append(" ");
sb.append(byteArrayToString(os, true));
return sb.toString();
}
}
|