1 /** 2 * 3 */ 4 package javax.jmdns.impl.constants; 5 6 /** 7 * DNS option code. 8 * 9 * @author Arthur van Hoff, Pierre Frisch, Rick Blair 10 */ 11 public enum DNSOptionCode { 12 13 /** 14 * Token 15 */ 16 Unknown("Unknown", 65535), 17 /** 18 * Long-Lived Queries Option [http://files.dns-sd.org/draft-sekar-dns-llq.txt] 19 */ 20 LLQ("LLQ", 1), 21 /** 22 * Update Leases Option [http://files.dns-sd.org/draft-sekar-dns-ul.txt] 23 */ 24 UL("UL", 2), 25 /** 26 * Name Server Identifier Option [RFC5001] 27 */ 28 NSID("NSID", 3), 29 /** 30 * Owner Option [draft-cheshire-edns0-owner-option] 31 */ 32 Owner("Owner", 4); 33 34 private final String _externalName; 35 36 private final int _index; 37 DNSOptionCode(String name, int index)38 DNSOptionCode(String name, int index) { 39 _externalName = name; 40 _index = index; 41 } 42 43 /** 44 * Return the string representation of this type 45 * 46 * @return String 47 */ externalName()48 public String externalName() { 49 return _externalName; 50 } 51 52 /** 53 * Return the numeric value of this type 54 * 55 * @return String 56 */ indexValue()57 public int indexValue() { 58 return _index; 59 } 60 61 /** 62 * @param optioncode 63 * @return label 64 */ resultCodeForFlags(int optioncode)65 public static DNSOptionCode resultCodeForFlags(int optioncode) { 66 int maskedIndex = optioncode; 67 for (DNSOptionCode aCode : DNSOptionCode.values()) { 68 if (aCode._index == maskedIndex) return aCode; 69 } 70 return Unknown; 71 } 72 73 @Override toString()74 public String toString() { 75 return this.name() + " index " + this.indexValue(); 76 } 77 78 } 79