1commit 9e42bff01440c1351946a432126d5a1b87fb7c78
2Author: Rene Treffer <treffer@measite.de>
3Date: Wed Jul 30 22:38:02 2014 +0200
4
5 Allow mdns multicast / unicast reply queries
6
7diff --git a/src/main/java/de/measite/minidns/Question.java b/src/main/java/de/measite/minidns/Question.java
8index 883003561..3b2fa1a13 100644
9--- a/src/main/java/de/measite/minidns/Question.java
10+++ b/src/main/java/de/measite/minidns/Question.java
11@@ -30,6 +30,11 @@ public class Question {
12 */
13 private final CLASS clazz;
14
15+ /**
16+ * UnicastQueries have the highest bit of the CLASS field set to 1.
17+ */
18+ private final boolean unicastQuery;
19+
20 /**
21 * Cache for the serialized object.
22 */
23@@ -41,10 +46,21 @@ public class Question {
24 * @param type The type, e.g. A.
25 * @param clazz The class, usually IN (internet).
26 */
27- public Question(String name, TYPE type, CLASS clazz) {
28+ public Question(String name, TYPE type, CLASS clazz, boolean unicastQuery) {
29 this.name = name;
30 this.type = type;
31 this.clazz = clazz;
32+ this.unicastQuery = unicastQuery;
33+ }
34+
35+ /**
36+ * Create a dns question for the given name/type/class.
37+ * @param name The name e.g. "measite.de".
38+ * @param type The type, e.g. A.
39+ * @param clazz The class, usually IN (internet).
40+ */
41+ public Question(String name, TYPE type, CLASS clazz) {
42+ this(name, type, clazz, false);
43 }
44
45 /**
46@@ -106,7 +122,7 @@ public class Question {
47 try {
48 dos.write(NameUtil.toByteArray(this.name));
49 dos.writeShort(type.getValue());
50- dos.writeShort(clazz.getValue());
51+ dos.writeShort(clazz.getValue() | (unicastQuery ? (1 << 15) : 0));
52 dos.flush();
53 } catch (IOException e) {
54 // Should never happen