001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: *
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: /**
020: * @author Alexei Y. Zakharov
021: * @version $Revision: 1.1.2.4 $
022: */package org.apache.harmony.jndi.provider.dns;
023:
024: import javax.naming.InvalidNameException;
025:
026: /**
027: * Contains various constants that are used in the provider classes.
028: *
029: * @see RFC 1035
030: */
031: public class ProviderConstants {
032:
033: // Constants that should be used as possible values for the header QR field
034: public static final boolean QR_QUERY = false;
035: public static final boolean QR_RESPONSE = true;
036:
037: // Message header masks
038: public static final int QR_MASK = 0x8000;
039: public static final int OPCODE_MASK = 0x7800;
040: public static final int AA_MASK = 0x400;
041: public static final int TC_MASK = 0x200;
042: public static final int RD_MASK = 0x100;
043: public static final int RA_MASK = 0x80;
044: public static final int Z_MASK = 0x70;
045: public static final int RCODE_MASK = 0xf;
046:
047: // Message header fields shifts
048: public static final int OPCODE_SHIFT = 11;
049: public static final int RCODE_SHIFT = 0;
050:
051: // Constants that can be used as OPCODEs in the header
052: public static final int QUERY = 0;
053: public static final int IQUERY = 1;
054: public static final int STATUS = 2;
055:
056: // Constants that can be used as RCODEs in the header
057: public static final int NO_ERROR = 0;
058: public static final int FORMAT_ERROR = 1;
059: public static final int SERVER_FAILURE = 2;
060: public static final int NAME_ERROR = 3;
061: public static final int NOT_IMPLEMENTED = 4;
062: public static final int REFUSED = 5;
063:
064: // Possible TYPE values
065: public static final int A_TYPE = 1;
066: public static final int NS_TYPE = 2;
067: public static final int MD_TYPE = 3;
068: public static final int MF_TYPE = 4;
069: public static final int CNAME_TYPE = 5;
070: public static final int SOA_TYPE = 6;
071: public static final int MB_TYPE = 7;
072: public static final int MG_TYPE = 8;
073: public static final int MR_TYPE = 9;
074: public static final int NULL_TYPE = 10;
075: public static final int WKS_TYPE = 11;
076: public static final int PTR_TYPE = 12;
077: public static final int HINFO_TYPE = 13;
078: public static final int MINFO_TYPE = 14;
079: public static final int MX_TYPE = 15;
080: public static final int TXT_TYPE = 16;
081: public static final int AAAA_TYPE = 28;
082: public static final int SRV_TYPE = 33;
083:
084: // Possible QTYPE values
085: public static final int AXFR_QTYPE = 252;
086: public static final int MAILB_QTYPE = 253;
087: public static final int MAILA_QTYPE = 254;
088: public static final int ANY_QTYPE = 255;
089:
090: public static String[] rrTypeNames;
091: public static String[] rrClassNames;
092:
093: // Possible CLASS values
094: public static final int IN_CLASS = 1;
095: public static final int CS_CLASS = 2;
096: public static final int CH_CLASS = 3;
097: public static final int HS_CLASS = 4;
098:
099: // Possible QCLASS values
100: public static final int ANY_QCLASS = 255;
101:
102: // Maximum lengths
103: public static final int LABEL_MAX_CHARS = 63;
104: public static final int NAME_MAX_CHARS = 255;
105:
106: // default DNS port
107: public static final int DEFAULT_DNS_PORT = 53;
108:
109: // Resolver settings
110: public static final int DEFAULT_INITIAL_TIMEOUT = 1000;
111: public static final int DEFAULT_TIMEOUT_RETRIES = 4;
112: public static final boolean DEFAULT_AUTHORITATIVE = false;
113: public static final boolean DEFAULT_RECURSION = true;
114: public static final int DEFAULT_LOOKUP_ATTR_TYPE = TXT_TYPE;
115: public static final int DEFAULT_LOOKUP_ATTR_CLASS = IN_CLASS;
116: public static final int DEFAULT_MAX_THREADS = 7;
117:
118: public static DNSName ROOT_ZONE_NAME_OBJ = null;
119:
120: // public static final String LOGGER_NAME =
121: // "org.apache.harmony.jndi.provider.dns";
122:
123: static {
124: // Resource Record types
125: // commented out types are not supported
126: rrTypeNames = new String[256];
127: for (int i = 0; i < 256; i++) {
128: rrTypeNames[i] = String.valueOf(i);
129: }
130: rrTypeNames[A_TYPE] = "A"; //$NON-NLS-1$
131: rrTypeNames[NS_TYPE] = "NS"; //$NON-NLS-1$
132: //rrTypeNames[MD_TYPE] = "MD";
133: //rrTypeNames[MF_TYPE] = "MF";
134: rrTypeNames[CNAME_TYPE] = "CNAME"; //$NON-NLS-1$
135: rrTypeNames[SOA_TYPE] = "SOA"; //$NON-NLS-1$
136: //rrTypeNames[MB_TYPE] = "MB";
137: //rrTypeNames[MG_TYPE] = "MG";
138: //rrTypeNames[MR_TYPE] = "MR";
139: //rrTypeNames[NULL_TYPE] = "NULL";
140: //rrTypeNames[WKS_TYPE] = "WKS";
141: rrTypeNames[PTR_TYPE] = "PTR"; //$NON-NLS-1$
142: rrTypeNames[HINFO_TYPE] = "HINFO"; //$NON-NLS-1$
143: //rrTypeNames[MINFO_TYPE] = "MINFO";
144: rrTypeNames[MX_TYPE] = "MX"; //$NON-NLS-1$
145: rrTypeNames[TXT_TYPE] = "TXT"; //$NON-NLS-1$
146: rrTypeNames[AAAA_TYPE] = "AAAA"; //$NON-NLS-1$
147: rrTypeNames[SRV_TYPE] = "SRV"; //$NON-NLS-1$
148: //rrTypeNames[AXFR_QTYPE] = "AXFR";
149: //rrTypeNames[MAILB_QTYPE] = "MAILB";
150: //rrTypeNames[MAILA_QTYPE] = "MAILA";
151: rrTypeNames[ANY_QTYPE] = "*"; //$NON-NLS-1$
152:
153: // Resource Record classes
154: rrClassNames = new String[256];
155: for (int i = 0; i < 256; i++) {
156: rrClassNames[i] = String.valueOf(i);
157: }
158: rrClassNames[IN_CLASS] = "IN"; //$NON-NLS-1$
159: rrClassNames[HS_CLASS] = "HS"; //$NON-NLS-1$
160: rrClassNames[ANY_QCLASS] = "*"; //$NON-NLS-1$
161:
162: // Root zone name
163: try {
164: ROOT_ZONE_NAME_OBJ = (DNSName) ((new DNSNameParser())
165: .parse(".")); //$NON-NLS-1$
166: } catch (InvalidNameException e) {
167: // ignore
168: }
169: }
170: }
|