diff options
author | Manuel Roman <manuelroman@google.com> | 2011-09-13 15:57:27 -0700 |
---|---|---|
committer | Manuel Roman <manuelroman@google.com> | 2011-09-13 16:49:34 -0700 |
commit | 3742d9db8b6edb10627b0f89336cca5249f1d15a (patch) | |
tree | 32a130b2a53160c4196bb23ec9ec7f25387f717d /src/javax/jmdns/impl/constants/DNSOptionCode.java | |
parent | 19376825c9e562c188aef9ccd09a7220bd3c0a20 (diff) | |
download | jmdns-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/DNSOptionCode.java')
-rw-r--r-- | src/javax/jmdns/impl/constants/DNSOptionCode.java | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/javax/jmdns/impl/constants/DNSOptionCode.java b/src/javax/jmdns/impl/constants/DNSOptionCode.java new file mode 100644 index 0000000..d039fac --- /dev/null +++ b/src/javax/jmdns/impl/constants/DNSOptionCode.java @@ -0,0 +1,78 @@ +/** + * + */ +package javax.jmdns.impl.constants; + +/** + * DNS option code. + * + * @author Arthur van Hoff, Pierre Frisch, Rick Blair + */ +public enum DNSOptionCode { + + /** + * Token + */ + Unknown("Unknown", 65535), + /** + * Long-Lived Queries Option [http://files.dns-sd.org/draft-sekar-dns-llq.txt] + */ + LLQ("LLQ", 1), + /** + * Update Leases Option [http://files.dns-sd.org/draft-sekar-dns-ul.txt] + */ + UL("UL", 2), + /** + * Name Server Identifier Option [RFC5001] + */ + NSID("NSID", 3), + /** + * Owner Option [draft-cheshire-edns0-owner-option] + */ + Owner("Owner", 4); + + private final String _externalName; + + private final int _index; + + DNSOptionCode(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 optioncode + * @return label + */ + public static DNSOptionCode resultCodeForFlags(int optioncode) { + int maskedIndex = optioncode; + for (DNSOptionCode aCode : DNSOptionCode.values()) { + if (aCode._index == maskedIndex) return aCode; + } + return Unknown; + } + + @Override + public String toString() { + return this.name() + " index " + this.indexValue(); + } + +} |