-
Notifications
You must be signed in to change notification settings - Fork 262
Expand file tree
/
Copy pathFlags.java
More file actions
73 lines (56 loc) · 1.77 KB
/
Flags.java
File metadata and controls
73 lines (56 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)
package org.xbill.DNS;
/**
* Constants and functions relating to flags in the DNS header.
*
* @author Brian Wellington
*/
public final class Flags {
private static final Mnemonic HEADER_FLAGS = new Mnemonic("DNS Header Flag", Mnemonic.CASE_LOWER);
/** query/response */
public static final byte QR = 0;
/** authoritative answer */
public static final byte AA = 5;
/** truncated */
public static final byte TC = 6;
/** recursion desired */
public static final byte RD = 7;
/** recursion available */
public static final byte RA = 8;
/** authenticated data */
public static final byte AD = 10;
/** (security) checking disabled */
public static final byte CD = 11;
/** dnssec ok (extended) */
public static final int DO = ExtendedFlags.DO;
static {
HEADER_FLAGS.setMaximum(0xF);
HEADER_FLAGS.setPrefix("FLAG");
HEADER_FLAGS.setNumericAllowed(true);
HEADER_FLAGS.add(QR, "qr");
HEADER_FLAGS.add(AA, "aa");
HEADER_FLAGS.add(TC, "tc");
HEADER_FLAGS.add(RD, "rd");
HEADER_FLAGS.add(RA, "ra");
HEADER_FLAGS.add(AD, "ad");
HEADER_FLAGS.add(CD, "cd");
}
private Flags() {}
/** Converts a numeric Flag into a String */
public static String string(int i) {
return HEADER_FLAGS.getText(i);
}
/** Converts a String representation of an Flag into its numeric value */
public static int value(String s) {
return HEADER_FLAGS.getValue(s);
}
/**
* Indicates if a bit in the flags field is a flag or not. If it's part of the rcode or opcode,
* it's not.
*/
public static boolean isFlag(int index) {
HEADER_FLAGS.check(index);
return (index < 1 || index > 4) && (index < 12);
}
}