01: // Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)
02:
03: package org.xbill.DNS;
04:
05: /**
06: * Constants and functions relating to flags in the DNS header.
07: *
08: * @author Brian Wellington
09: */
10:
11: public final class Flags {
12:
13: private static Mnemonic flags = new Mnemonic("DNS Header Flag",
14: Mnemonic.CASE_LOWER);
15:
16: /** query/response */
17: public static final byte QR = 0;
18:
19: /** authoritative answer */
20: public static final byte AA = 5;
21:
22: /** truncated */
23: public static final byte TC = 6;
24:
25: /** recursion desired */
26: public static final byte RD = 7;
27:
28: /** recursion available */
29: public static final byte RA = 8;
30:
31: /** authenticated data */
32: public static final byte AD = 10;
33:
34: /** (security) checking disabled */
35: public static final byte CD = 11;
36:
37: /** dnssec ok (extended) */
38: public static final int DO = ExtendedFlags.DO;
39:
40: static {
41: flags.setMaximum(0xF);
42: flags.setPrefix("FLAG");
43: flags.setNumericAllowed(true);
44:
45: flags.add(QR, "qr");
46: flags.add(AA, "aa");
47: flags.add(TC, "tc");
48: flags.add(RD, "rd");
49: flags.add(RA, "ra");
50: flags.add(AD, "ad");
51: flags.add(CD, "cd");
52: }
53:
54: private Flags() {
55: }
56:
57: /** Converts a numeric Flag into a String */
58: public static String string(int i) {
59: return flags.getText(i);
60: }
61:
62: /** Converts a String representation of an Flag into its numeric value */
63: public static int value(String s) {
64: return flags.getValue(s);
65: }
66:
67: /**
68: * Indicates if a bit in the flags field is a flag or not. If it's part of
69: * the rcode or opcode, it's not.
70: */
71: public static boolean isFlag(int index) {
72: flags.check(index);
73: if ((index >= 1 && index <= 4) || (index >= 12))
74: return false;
75: return true;
76: }
77:
78: }
|