1 /** 2 * 3 */ 4 package javax.jmdns.impl.constants; 5 6 import java.util.logging.Logger; 7 8 /** 9 * DNS Record Type 10 * 11 * @author Arthur van Hoff, Jeff Sonstein, Werner Randelshofer, Pierre Frisch, Rick Blair 12 */ 13 public enum DNSRecordType { 14 /** 15 * Address 16 */ 17 TYPE_IGNORE("ignore", 0), 18 /** 19 * Address 20 */ 21 TYPE_A("a", 1), 22 /** 23 * Name Server 24 */ 25 TYPE_NS("ns", 2), 26 /** 27 * Mail Destination 28 */ 29 TYPE_MD("md", 3), 30 /** 31 * Mail Forwarder 32 */ 33 TYPE_MF("mf", 4), 34 /** 35 * Canonical Name 36 */ 37 TYPE_CNAME("cname", 5), 38 /** 39 * Start of Authority 40 */ 41 TYPE_SOA("soa", 6), 42 /** 43 * Mailbox 44 */ 45 TYPE_MB("mb", 7), 46 /** 47 * Mail Group 48 */ 49 TYPE_MG("mg", 8), 50 /** 51 * Mail Rename 52 */ 53 TYPE_MR("mr", 9), 54 /** 55 * NULL RR 56 */ 57 TYPE_NULL("null", 10), 58 /** 59 * Well-known-service 60 */ 61 TYPE_WKS("wks", 11), 62 /** 63 * Domain Name pointer 64 */ 65 TYPE_PTR("ptr", 12), 66 /** 67 * Host information 68 */ 69 TYPE_HINFO("hinfo", 13), 70 /** 71 * Mailbox information 72 */ 73 TYPE_MINFO("minfo", 14), 74 /** 75 * Mail exchanger 76 */ 77 TYPE_MX("mx", 15), 78 /** 79 * Arbitrary text string 80 */ 81 TYPE_TXT("txt", 16), 82 /** 83 * for Responsible Person [RFC1183] 84 */ 85 TYPE_RP("rp", 17), 86 /** 87 * for AFS Data Base location [RFC1183] 88 */ 89 TYPE_AFSDB("afsdb", 18), 90 /** 91 * for X.25 PSDN address [RFC1183] 92 */ 93 TYPE_X25("x25", 19), 94 /** 95 * for ISDN address [RFC1183] 96 */ 97 TYPE_ISDN("isdn", 20), 98 /** 99 * for Route Through [RFC1183] 100 */ 101 TYPE_RT("rt", 21), 102 /** 103 * for NSAP address, NSAP style A record [RFC1706] 104 */ 105 TYPE_NSAP("nsap", 22), 106 /** 107 * 108 */ 109 TYPE_NSAP_PTR("nsap-otr", 23), 110 /** 111 * for security signature [RFC2931] 112 */ 113 TYPE_SIG("sig", 24), 114 /** 115 * for security key [RFC2535] 116 */ 117 TYPE_KEY("key", 25), 118 /** 119 * X.400 mail mapping information [RFC2163] 120 */ 121 TYPE_PX("px", 26), 122 /** 123 * Geographical Position [RFC1712] 124 */ 125 TYPE_GPOS("gpos", 27), 126 /** 127 * IP6 Address [Thomson] 128 */ 129 TYPE_AAAA("aaaa", 28), 130 /** 131 * Location Information [Vixie] 132 */ 133 TYPE_LOC("loc", 29), 134 /** 135 * Next Domain - OBSOLETE [RFC2535, RFC3755] 136 */ 137 TYPE_NXT("nxt", 30), 138 /** 139 * Endpoint Identifier [Patton] 140 */ 141 TYPE_EID("eid", 31), 142 /** 143 * Nimrod Locator [Patton] 144 */ 145 TYPE_NIMLOC("nimloc", 32), 146 /** 147 * Server Selection [RFC2782] 148 */ 149 TYPE_SRV("srv", 33), 150 /** 151 * ATM Address [Dobrowski] 152 */ 153 TYPE_ATMA("atma", 34), 154 /** 155 * Naming Authority Pointer [RFC2168, RFC2915] 156 */ 157 TYPE_NAPTR("naptr", 35), 158 /** 159 * Key Exchanger [RFC2230] 160 */ 161 TYPE_KX("kx", 36), 162 /** 163 * CERT [RFC2538] 164 */ 165 TYPE_CERT("cert", 37), 166 /** 167 * A6 [RFC2874] 168 */ 169 TYPE_A6("a6", 38), 170 /** 171 * DNAME [RFC2672] 172 */ 173 TYPE_DNAME("dname", 39), 174 /** 175 * SINK [Eastlake] 176 */ 177 TYPE_SINK("sink", 40), 178 /** 179 * OPT [RFC2671] 180 */ 181 TYPE_OPT("opt", 41), 182 /** 183 * APL [RFC3123] 184 */ 185 TYPE_APL("apl", 42), 186 /** 187 * Delegation Signer [RFC3658] 188 */ 189 TYPE_DS("ds", 43), 190 /** 191 * SSH Key Fingerprint [RFC-ietf-secsh-dns-05.txt] 192 */ 193 TYPE_SSHFP("sshfp", 44), 194 /** 195 * RRSIG [RFC3755] 196 */ 197 TYPE_RRSIG("rrsig", 46), 198 /** 199 * NSEC [RFC3755] 200 */ 201 TYPE_NSEC("nsec", 47), 202 /** 203 * DNSKEY [RFC3755] 204 */ 205 TYPE_DNSKEY("dnskey", 48), 206 /** 207 * [IANA-Reserved] 208 */ 209 TYPE_UINFO("uinfo", 100), 210 /** 211 * [IANA-Reserved] 212 */ 213 TYPE_UID("uid", 101), 214 /** 215 * [IANA-Reserved] 216 */ 217 TYPE_GID("gid", 102), 218 /** 219 * [IANA-Reserved] 220 */ 221 TYPE_UNSPEC("unspec", 103), 222 /** 223 * Transaction Key [RFC2930] 224 */ 225 TYPE_TKEY("tkey", 249), 226 /** 227 * Transaction Signature [RFC2845] 228 */ 229 TYPE_TSIG("tsig", 250), 230 /** 231 * Incremental transfer [RFC1995] 232 */ 233 TYPE_IXFR("ixfr", 251), 234 /** 235 * Transfer of an entire zone [RFC1035] 236 */ 237 TYPE_AXFR("axfr", 252), 238 /** 239 * Mailbox-related records (MB, MG or MR) [RFC1035] 240 */ 241 TYPE_MAILA("mails", 253), 242 /** 243 * Mail agent RRs (Obsolete - see MX) [RFC1035] 244 */ 245 TYPE_MAILB("mailb", 254), 246 /** 247 * Request for all records [RFC1035] 248 */ 249 TYPE_ANY("any", 255); 250 251 private static Logger logger = Logger.getLogger(DNSRecordType.class.getName()); 252 253 private final String _externalName; 254 255 private final int _index; 256 DNSRecordType(String name, int index)257 DNSRecordType(String name, int index) { 258 _externalName = name; 259 _index = index; 260 } 261 262 /** 263 * Return the string representation of this type 264 * 265 * @return String 266 */ externalName()267 public String externalName() { 268 return _externalName; 269 } 270 271 /** 272 * Return the numeric value of this type 273 * 274 * @return String 275 */ indexValue()276 public int indexValue() { 277 return _index; 278 } 279 280 /** 281 * @param name 282 * @return type for name 283 */ typeForName(String name)284 public static DNSRecordType typeForName(String name) { 285 if (name != null) { 286 String aName = name.toLowerCase(); 287 for (DNSRecordType aType : DNSRecordType.values()) { 288 if (aType._externalName.equals(aName)) return aType; 289 } 290 } 291 logger.severe("Could not find record type for name: " + name); 292 return TYPE_IGNORE; 293 } 294 295 /** 296 * @param index 297 * @return type for name 298 */ typeForIndex(int index)299 public static DNSRecordType typeForIndex(int index) { 300 for (DNSRecordType aType : DNSRecordType.values()) { 301 if (aType._index == index) return aType; 302 } 303 logger.severe("Could not find record type for index: " + index); 304 return TYPE_IGNORE; 305 } 306 307 @Override toString()308 public String toString() { 309 return this.name() + " index " + this.indexValue(); 310 } 311 312 } 313