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