Home | History | Annotate | Download | only in DNS
      1 // Copyright (c) 1999-2004 Brian Wellington (bwelling (at) xbill.org)
      2 
      3 package org.xbill.DNS;
      4 
      5 /**
      6  * Constants and functions relating to DNS opcodes
      7  *
      8  * @author Brian Wellington
      9  */
     10 
     11 public final class Opcode {
     12 
     13 /** A standard query */
     14 public static final int QUERY		= 0;
     15 
     16 /** An inverse query (deprecated) */
     17 public static final int IQUERY		= 1;
     18 
     19 /** A server status request (not used) */
     20 public static final int STATUS		= 2;
     21 
     22 /**
     23  * A message from a primary to a secondary server to initiate a zone transfer
     24  */
     25 public static final int NOTIFY		= 4;
     26 
     27 /** A dynamic update message */
     28 public static final int UPDATE		= 5;
     29 
     30 private static Mnemonic opcodes = new Mnemonic("DNS Opcode",
     31 					       Mnemonic.CASE_UPPER);
     32 
     33 static {
     34 	opcodes.setMaximum(0xF);
     35 	opcodes.setPrefix("RESERVED");
     36 	opcodes.setNumericAllowed(true);
     37 
     38 	opcodes.add(QUERY, "QUERY");
     39 	opcodes.add(IQUERY, "IQUERY");
     40 	opcodes.add(STATUS, "STATUS");
     41 	opcodes.add(NOTIFY, "NOTIFY");
     42 	opcodes.add(UPDATE, "UPDATE");
     43 }
     44 
     45 private
     46 Opcode() {}
     47 
     48 /** Converts a numeric Opcode into a String */
     49 public static String
     50 string(int i) {
     51 	return opcodes.getText(i);
     52 }
     53 
     54 /** Converts a String representation of an Opcode into its numeric value */
     55 public static int
     56 value(String s) {
     57 	return opcodes.getValue(s);
     58 }
     59 
     60 }
     61