Class DnsPacket.DnsHeader
java.lang.Object
org.pcap4j.packet.AbstractPacket.AbstractHeader
org.pcap4j.packet.DnsPacket.DnsHeader
- All Implemented Interfaces:
Serializable, Packet.Header
- Enclosing class:
DnsPacket
DNS header
+---------------------+
| Header |
+---------------------+
| Question | the question for the name server
+---------------------+
| Answer | RRs answering the question
+---------------------+
| Authority | RRs pointing toward an authority
+---------------------+
| Additional | RRs holding additional information
+---------------------+
Header:
1 1 1 1 1 1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| ID |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|QR| Opcode |AA|TC|RD|RA| Z|AD|CD| RCODE |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| QDCOUNT |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| ANCOUNT |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| NSCOUNT |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| ARCOUNT |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
- Since:
- pcap4j 1.7.1
- Version:
- pcap4j 1.7.1
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<DnsResourceRecord> private final shortprivate static final intprivate static final intprivate final List<DnsResourceRecord> private final shortprivate static final intprivate static final intprivate final booleanprivate final booleanprivate final List<DnsResourceRecord> private final booleanprivate static final intprivate static final intprivate static final intprivate final shortprivate static final intprivate static final intprivate final shortprivate static final intprivate static final intprivate final DnsOpCodeprivate final shortprivate static final intprivate static final intprivate final List<DnsQuestion> private final DnsRCodeprivate final booleanprivate final booleanprivate final booleanprivate final booleanprivate static final longprivate final boolean -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateDnsHeader(byte[] rawData, int offset, int length) privateDnsHeader(DnsPacket.Builder builder) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringThis method builds the valuetoString()will return.protected intThis method builds the valuehashCode()will return using the byte arraygetRawData()returns.booleanIndicates whether some other object is "equal to" this one using return values ofgetRawData().shortintshortintshortgetId()shortintshortintprotected List<byte[]> Returns a list of byte arrays which represents this header's fields.getrCode()booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanintlength()Returns the header length in bytes.Methods inherited from class AbstractPacket.AbstractHeader
buildHexString, buildRawData, calcLength, getRawData, hashCode, toHexString, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
ID_OFFSET
private static final int ID_OFFSET- See Also:
-
ID_SIZE
private static final int ID_SIZE- See Also:
-
FLAGS_OFFSET
private static final int FLAGS_OFFSET- See Also:
-
FLAGS_SIZE
private static final int FLAGS_SIZE- See Also:
-
QDCOUNT_OFFSET
private static final int QDCOUNT_OFFSET- See Also:
-
QDCOUNT_SIZE
private static final int QDCOUNT_SIZE- See Also:
-
ANCOUNT_OFFSET
private static final int ANCOUNT_OFFSET- See Also:
-
ANCOUNT_SIZE
private static final int ANCOUNT_SIZE- See Also:
-
NSCOUNT_OFFSET
private static final int NSCOUNT_OFFSET- See Also:
-
NSCOUNT_SIZE
private static final int NSCOUNT_SIZE- See Also:
-
ARCOUNT_OFFSET
private static final int ARCOUNT_OFFSET- See Also:
-
ARCOUNT_SIZE
private static final int ARCOUNT_SIZE- See Also:
-
DNS_MIN_HEADER_SIZE
private static final int DNS_MIN_HEADER_SIZE- See Also:
-
id
private final short id -
response
private final boolean response -
opCode
-
authoritativeAnswer
private final boolean authoritativeAnswer -
truncated
private final boolean truncated -
recursionDesired
private final boolean recursionDesired -
recursionAvailable
private final boolean recursionAvailable -
reserved
private final boolean reserved -
authenticData
private final boolean authenticData -
checkingDisabled
private final boolean checkingDisabled -
rCode
-
qdCount
private final short qdCount -
anCount
private final short anCount -
nsCount
private final short nsCount -
arCount
private final short arCount -
questions
-
answers
-
authorities
-
additionalInfo
-
-
Constructor Details
-
DnsHeader
- Throws:
IllegalRawDataException
-
DnsHeader
-
-
Method Details
-
getId
public short getId()- Returns:
- id
-
isResponse
public boolean isResponse()- Returns:
- true if the QR bit is set to 1; false otherwise.
-
getOpCode
- Returns:
- opCode
-
isAuthoritativeAnswer
public boolean isAuthoritativeAnswer()- Returns:
- true if the AA bit is set to 1; false otherwise.
-
isTruncated
public boolean isTruncated()- Returns:
- true if the TC bit is set to 1; false otherwise.
-
isRecursionDesired
public boolean isRecursionDesired()- Returns:
- true if the RD bit is set to 1; false otherwise.
-
isRecursionAvailable
public boolean isRecursionAvailable()- Returns:
- true if the RA bit is set to 1; false otherwise.
-
getReservedBit
public boolean getReservedBit()- Returns:
- true if the Z bit is set to 1; false otherwise.
-
isAuthenticData
public boolean isAuthenticData()- Returns:
- true if the AD bit is set to 1; false otherwise.
-
isCheckingDisabled
public boolean isCheckingDisabled()- Returns:
- true if the CD bit is set to 1; false otherwise.
-
getrCode
- Returns:
- rCode
-
getQdCount
public short getQdCount()- Returns:
- qdCount
-
getQdCountAsInt
public int getQdCountAsInt()- Returns:
- qdCount
-
getAnCount
public short getAnCount()- Returns:
- anCount
-
getAnCountAsInt
public int getAnCountAsInt()- Returns:
- anCount
-
getNsCount
public short getNsCount()- Returns:
- nsCount
-
getNsCountAsInt
public int getNsCountAsInt()- Returns:
- nsCount
-
getArCount
public short getArCount()- Returns:
- arCount
-
getArCountAsInt
public int getArCountAsInt()- Returns:
- arCount
-
getQuestions
- Returns:
- questions
-
getAnswers
- Returns:
- answers
-
getAuthorities
- Returns:
- authorities
-
getAdditionalInfo
- Returns:
- additionalInfo
-
getRawFields
Description copied from class:AbstractPacket.AbstractHeaderReturns a list of byte arrays which represents this header's fields. This method is called bycalcLength()andbuildRawData().- Specified by:
getRawFieldsin classAbstractPacket.AbstractHeader- Returns:
- a list of byte arrays which represents this header's fields
-
length
public int length()Description copied from class:AbstractPacket.AbstractHeaderReturns the header length in bytes. This method callscalcLength()and caches the return value when it is called for the first time, and then, this method returns the cached value from the second time.- Specified by:
lengthin interfacePacket.Header- Overrides:
lengthin classAbstractPacket.AbstractHeader- Returns:
- the length of the byte stream of the header represented by this object in bytes
-
buildString
Description copied from class:AbstractPacket.AbstractHeaderThis method builds the valuetoString()will return.- Overrides:
buildStringin classAbstractPacket.AbstractHeader- Returns:
- a string representation of this object
-
equals
Description copied from class:AbstractPacket.AbstractHeaderIndicates whether some other object is "equal to" this one using return values ofgetRawData(). This method should be overridden so that it does more strict comparisons more efficiently.- Overrides:
equalsin classAbstractPacket.AbstractHeader
-
calcHashCode
protected int calcHashCode()Description copied from class:AbstractPacket.AbstractHeaderThis method builds the valuehashCode()will return using the byte arraygetRawData()returns. This method may be better to be overridden for performance reason.- Overrides:
calcHashCodein classAbstractPacket.AbstractHeader- Returns:
- a calculated hash code value for the object
-