001: // Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)
002:
003: package org.xbill.DNS;
004:
005: /**
006: * Constants and functions relating to DNS rcodes (error values)
007: *
008: * @author Brian Wellington
009: */
010:
011: public final class Rcode {
012:
013: private static Mnemonic rcodes = new Mnemonic("DNS Rcode",
014: Mnemonic.CASE_UPPER);
015:
016: private static Mnemonic tsigrcodes = new Mnemonic("TSIG rcode",
017: Mnemonic.CASE_UPPER);
018:
019: /** No error */
020: public static final int NOERROR = 0;
021:
022: /** Format error */
023: public static final int FORMERR = 1;
024:
025: /** Server failure */
026: public static final int SERVFAIL = 2;
027:
028: /** The name does not exist */
029: public static final int NXDOMAIN = 3;
030:
031: /** The operation requested is not implemented */
032: public static final int NOTIMP = 4;
033:
034: /** Deprecated synonym for NOTIMP. */
035: public static final int NOTIMPL = 4;
036:
037: /** The operation was refused by the server */
038: public static final int REFUSED = 5;
039:
040: /** The name exists */
041: public static final int YXDOMAIN = 6;
042:
043: /** The RRset (name, type) exists */
044: public static final int YXRRSET = 7;
045:
046: /** The RRset (name, type) does not exist */
047: public static final int NXRRSET = 8;
048:
049: /** The requestor is not authorized to perform this operation */
050: public static final int NOTAUTH = 9;
051:
052: /** The zone specified is not a zone */
053: public static final int NOTZONE = 10;
054:
055: /* EDNS extended rcodes */
056: /** Unsupported EDNS level */
057: public static final int BADVERS = 16;
058:
059: /* TSIG/TKEY only rcodes */
060: /** The signature is invalid (TSIG/TKEY extended error) */
061: public static final int BADSIG = 16;
062:
063: /** The key is invalid (TSIG/TKEY extended error) */
064: public static final int BADKEY = 17;
065:
066: /** The time is out of range (TSIG/TKEY extended error) */
067: public static final int BADTIME = 18;
068:
069: /** The mode is invalid (TKEY extended error) */
070: public static final int BADMODE = 19;
071:
072: static {
073: rcodes.setMaximum(0xFFF);
074: rcodes.setPrefix("RESERVED");
075: rcodes.setNumericAllowed(true);
076:
077: rcodes.add(NOERROR, "NOERROR");
078: rcodes.add(FORMERR, "FORMERR");
079: rcodes.add(SERVFAIL, "SERVFAIL");
080: rcodes.add(NXDOMAIN, "NXDOMAIN");
081: rcodes.add(NOTIMP, "NOTIMP");
082: rcodes.addAlias(NOTIMP, "NOTIMPL");
083: rcodes.add(REFUSED, "REFUSED");
084: rcodes.add(YXDOMAIN, "YXDOMAIN");
085: rcodes.add(YXRRSET, "YXRRSET");
086: rcodes.add(NXRRSET, "NXRRSET");
087: rcodes.add(NOTAUTH, "NOTAUTH");
088: rcodes.add(NOTZONE, "NOTZONE");
089: rcodes.add(BADVERS, "BADVERS");
090:
091: tsigrcodes.setMaximum(0xFFFF);
092: tsigrcodes.setPrefix("RESERVED");
093: tsigrcodes.setNumericAllowed(true);
094: tsigrcodes.addAll(rcodes);
095:
096: tsigrcodes.add(BADSIG, "BADSIG");
097: tsigrcodes.add(BADKEY, "BADKEY");
098: tsigrcodes.add(BADTIME, "BADTIME");
099: tsigrcodes.add(BADMODE, "BADMODE");
100: }
101:
102: private Rcode() {
103: }
104:
105: /** Converts a numeric Rcode into a String */
106: public static String string(int i) {
107: return rcodes.getText(i);
108: }
109:
110: /** Converts a numeric TSIG extended Rcode into a String */
111: public static String TSIGstring(int i) {
112: return tsigrcodes.getText(i);
113: }
114:
115: /** Converts a String representation of an Rcode into its numeric value */
116: public static int value(String s) {
117: return rcodes.getValue(s);
118: }
119:
120: }
|