• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)
2 
3 package org.xbill.DNS;
4 
5 /**
6  * Constants and functions relating to DNS rcodes (error values)
7  *
8  * @author Brian Wellington
9  */
10 
11 public final class Rcode {
12 
13 private static Mnemonic rcodes = new Mnemonic("DNS Rcode",
14 					      Mnemonic.CASE_UPPER);
15 
16 private static Mnemonic tsigrcodes = new Mnemonic("TSIG rcode",
17 						  Mnemonic.CASE_UPPER);
18 
19 /** No error */
20 public static final int NOERROR		= 0;
21 
22 /** Format error */
23 public static final int FORMERR		= 1;
24 
25 /** Server failure */
26 public static final int SERVFAIL	= 2;
27 
28 /** The name does not exist */
29 public static final int NXDOMAIN	= 3;
30 
31 /** The operation requested is not implemented */
32 public static final int NOTIMP		= 4;
33 
34 /** Deprecated synonym for NOTIMP. */
35 public static final int NOTIMPL		= 4;
36 
37 /** The operation was refused by the server */
38 public static final int REFUSED		= 5;
39 
40 /** The name exists */
41 public static final int YXDOMAIN	= 6;
42 
43 /** The RRset (name, type) exists */
44 public static final int YXRRSET		= 7;
45 
46 /** The RRset (name, type) does not exist */
47 public static final int NXRRSET		= 8;
48 
49 /** The requestor is not authorized to perform this operation */
50 public static final int NOTAUTH		= 9;
51 
52 /** The zone specified is not a zone */
53 public static final int NOTZONE		= 10;
54 
55 /* EDNS extended rcodes */
56 /** Unsupported EDNS level */
57 public static final int BADVERS		= 16;
58 
59 /* TSIG/TKEY only rcodes */
60 /** The signature is invalid (TSIG/TKEY extended error) */
61 public static final int BADSIG		= 16;
62 
63 /** The key is invalid (TSIG/TKEY extended error) */
64 public static final int BADKEY		= 17;
65 
66 /** The time is out of range (TSIG/TKEY extended error) */
67 public static final int BADTIME		= 18;
68 
69 /** The mode is invalid (TKEY extended error) */
70 public static final int BADMODE		= 19;
71 
72 static {
73 	rcodes.setMaximum(0xFFF);
74 	rcodes.setPrefix("RESERVED");
75 	rcodes.setNumericAllowed(true);
76 
rcodes.add(NOERROR, "NOERROR")77 	rcodes.add(NOERROR, "NOERROR");
rcodes.add(FORMERR, "FORMERR")78 	rcodes.add(FORMERR, "FORMERR");
rcodes.add(SERVFAIL, "SERVFAIL")79 	rcodes.add(SERVFAIL, "SERVFAIL");
rcodes.add(NXDOMAIN, "NXDOMAIN")80 	rcodes.add(NXDOMAIN, "NXDOMAIN");
rcodes.add(NOTIMP, "NOTIMP")81 	rcodes.add(NOTIMP, "NOTIMP");
rcodes.addAlias(NOTIMP, "NOTIMPL")82 	rcodes.addAlias(NOTIMP, "NOTIMPL");
rcodes.add(REFUSED, "REFUSED")83 	rcodes.add(REFUSED, "REFUSED");
rcodes.add(YXDOMAIN, "YXDOMAIN")84 	rcodes.add(YXDOMAIN, "YXDOMAIN");
rcodes.add(YXRRSET, "YXRRSET")85 	rcodes.add(YXRRSET, "YXRRSET");
rcodes.add(NXRRSET, "NXRRSET")86 	rcodes.add(NXRRSET, "NXRRSET");
rcodes.add(NOTAUTH, "NOTAUTH")87 	rcodes.add(NOTAUTH, "NOTAUTH");
rcodes.add(NOTZONE, "NOTZONE")88 	rcodes.add(NOTZONE, "NOTZONE");
rcodes.add(BADVERS, "BADVERS")89 	rcodes.add(BADVERS, "BADVERS");
90 
91 	tsigrcodes.setMaximum(0xFFFF);
92 	tsigrcodes.setPrefix("RESERVED");
93 	tsigrcodes.setNumericAllowed(true);
94 	tsigrcodes.addAll(rcodes);
95 
tsigrcodes.add(BADSIG, "BADSIG")96 	tsigrcodes.add(BADSIG, "BADSIG");
tsigrcodes.add(BADKEY, "BADKEY")97 	tsigrcodes.add(BADKEY, "BADKEY");
tsigrcodes.add(BADTIME, "BADTIME")98 	tsigrcodes.add(BADTIME, "BADTIME");
tsigrcodes.add(BADMODE, "BADMODE")99 	tsigrcodes.add(BADMODE, "BADMODE");
100 }
101 
102 private
Rcode()103 Rcode() {}
104 
105 /** Converts a numeric Rcode into a String */
106 public static String
string(int i)107 string(int i) {
108 	return rcodes.getText(i);
109 }
110 
111 /** Converts a numeric TSIG extended Rcode into a String */
112 public static String
TSIGstring(int i)113 TSIGstring(int i) {
114 	return tsigrcodes.getText(i);
115 }
116 
117 /** Converts a String representation of an Rcode into its numeric value */
118 public static int
value(String s)119 value(String s) {
120 	return rcodes.getValue(s);
121 }
122 
123 }
124