1
2
3
4
5 package javax.jmdns.impl.tasks.resolver;
6
7 import java.io.IOException;
8
9 import javax.jmdns.impl.DNSOutgoing;
10 import javax.jmdns.impl.DNSQuestion;
11 import javax.jmdns.impl.DNSRecord;
12 import javax.jmdns.impl.JmDNSImpl;
13 import javax.jmdns.impl.JmDNSImpl.ServiceTypeEntry;
14 import javax.jmdns.impl.constants.DNSConstants;
15 import javax.jmdns.impl.constants.DNSRecordClass;
16 import javax.jmdns.impl.constants.DNSRecordType;
17
18
19
20
21
22
23
24
25 public class TypeResolver extends DNSResolverTask {
26
27
28
29
30 public TypeResolver(JmDNSImpl jmDNSImpl) {
31 super(jmDNSImpl);
32 }
33
34
35
36
37
38 @Override
39 public String getName() {
40 return "TypeResolver(" + (this.getDns() != null ? this.getDns().getName() : "") + ")";
41 }
42
43
44
45
46
47 @Override
48 protected DNSOutgoing addAnswers(DNSOutgoing out) throws IOException {
49 DNSOutgoing newOut = out;
50 long now = System.currentTimeMillis();
51 for (String type : this.getDns().getServiceTypes().keySet()) {
52 ServiceTypeEntry typeEntry = this.getDns().getServiceTypes().get(type);
53 newOut = this.addAnswer(newOut, new DNSRecord.Pointer("_services._dns-sd._udp.local.", DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, DNSConstants.DNS_TTL, typeEntry.getType()), now);
54 }
55 return newOut;
56 }
57
58
59
60
61
62 @Override
63 protected DNSOutgoing addQuestions(DNSOutgoing out) throws IOException {
64 return this.addQuestion(out, DNSQuestion.newQuestion("_services._dns-sd._udp.local.", DNSRecordType.TYPE_PTR, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
65 }
66
67
68
69
70
71 @Override
72 protected String description() {
73 return "querying type";
74 }
75 }