1
2
3
4 package javax.jmdns.impl.constants;
5
6
7
8
9
10
11 public enum DNSOperationCode {
12
13
14
15 Query("Query", 0),
16
17
18
19 IQuery("Inverse Query", 1),
20
21
22
23 Status("Status", 2),
24
25
26
27 Unassigned("Unassigned", 3),
28
29
30
31 Notify("Notify", 4),
32
33
34
35 Update("Update", 5);
36
37
38
39
40 static final int OpCode_MASK = 0x7800;
41
42 private final String _externalName;
43
44 private final int _index;
45
46 DNSOperationCode(String name, int index) {
47 _externalName = name;
48 _index = index;
49 }
50
51
52
53
54
55
56 public String externalName() {
57 return _externalName;
58 }
59
60
61
62
63
64
65 public int indexValue() {
66 return _index;
67 }
68
69
70
71
72
73 public static DNSOperationCode operationCodeForFlags(int flags) {
74 int maskedIndex = (flags & OpCode_MASK) >> 11;
75 for (DNSOperationCode aCode : DNSOperationCode.values()) {
76 if (aCode._index == maskedIndex) return aCode;
77 }
78 return Unassigned;
79 }
80
81 @Override
82 public String toString() {
83 return this.name() + " index " + this.indexValue();
84 }
85
86 }