summaryrefslogtreecommitdiff
path: root/src/javax/jmdns/impl/constants/DNSOperationCode.java
diff options
context:
space:
mode:
authorManuel Roman <manuelroman@google.com>2011-09-13 15:57:27 -0700
committerManuel Roman <manuelroman@google.com>2011-09-13 16:49:34 -0700
commit3742d9db8b6edb10627b0f89336cca5249f1d15a (patch)
tree32a130b2a53160c4196bb23ec9ec7f25387f717d /src/javax/jmdns/impl/constants/DNSOperationCode.java
parent19376825c9e562c188aef9ccd09a7220bd3c0a20 (diff)
downloadjmdns-3742d9db8b6edb10627b0f89336cca5249f1d15a.tar.gz
Uploading the original JmDNS code
This code is used by the Broker service to advertise and discover an Active Home using the standard mDNS protocol Change-Id: I5d7068765b4ca771e3f3faf5d12104e2247945f3
Diffstat (limited to 'src/javax/jmdns/impl/constants/DNSOperationCode.java')
-rw-r--r--src/javax/jmdns/impl/constants/DNSOperationCode.java86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/javax/jmdns/impl/constants/DNSOperationCode.java b/src/javax/jmdns/impl/constants/DNSOperationCode.java
new file mode 100644
index 0000000..86af38f
--- /dev/null
+++ b/src/javax/jmdns/impl/constants/DNSOperationCode.java
@@ -0,0 +1,86 @@
+/**
+ *
+ */
+package javax.jmdns.impl.constants;
+
+/**
+ * DNS operation code.
+ *
+ * @author Arthur van Hoff, Jeff Sonstein, Werner Randelshofer, Pierre Frisch, Rick Blair
+ */
+public enum DNSOperationCode {
+ /**
+ * Query [RFC1035]
+ */
+ Query("Query", 0),
+ /**
+ * IQuery (Inverse Query, Obsolete) [RFC3425]
+ */
+ IQuery("Inverse Query", 1),
+ /**
+ * Status [RFC1035]
+ */
+ Status("Status", 2),
+ /**
+ * Unassigned
+ */
+ Unassigned("Unassigned", 3),
+ /**
+ * Notify [RFC1996]
+ */
+ Notify("Notify", 4),
+ /**
+ * Update [RFC2136]
+ */
+ Update("Update", 5);
+
+ /**
+ * DNS RCode types are encoded on the last 4 bits
+ */
+ static final int OpCode_MASK = 0x7800;
+
+ private final String _externalName;
+
+ private final int _index;
+
+ DNSOperationCode(String name, int index) {
+ _externalName = name;
+ _index = index;
+ }
+
+ /**
+ * Return the string representation of this type
+ *
+ * @return String
+ */
+ public String externalName() {
+ return _externalName;
+ }
+
+ /**
+ * Return the numeric value of this type
+ *
+ * @return String
+ */
+ public int indexValue() {
+ return _index;
+ }
+
+ /**
+ * @param flags
+ * @return label
+ */
+ public static DNSOperationCode operationCodeForFlags(int flags) {
+ int maskedIndex = (flags & OpCode_MASK) >> 11;
+ for (DNSOperationCode aCode : DNSOperationCode.values()) {
+ if (aCode._index == maskedIndex) return aCode;
+ }
+ return Unassigned;
+ }
+
+ @Override
+ public String toString() {
+ return this.name() + " index " + this.indexValue();
+ }
+
+}