- java.lang.Object
-
- org.pcap4j.packet.AbstractPacket.AbstractHeader
-
- org.pcap4j.packet.DnsPacket.DnsHeader
-
- All Implemented Interfaces:
java.io.Serializable,Packet.Header
- Enclosing class:
- DnsPacket
public static final class DnsPacket.DnsHeader extends AbstractPacket.AbstractHeader
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 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+- Version:
- pcap4j 1.7.1
- See Also:
- RFC 1035, RFC 2535, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<DnsResourceRecord>additionalInfoprivate shortanCountprivate static intANCOUNT_OFFSETprivate static intANCOUNT_SIZEprivate java.util.List<DnsResourceRecord>answersprivate shortarCountprivate static intARCOUNT_OFFSETprivate static intARCOUNT_SIZEprivate booleanauthenticDataprivate booleanauthoritativeAnswerprivate java.util.List<DnsResourceRecord>authoritiesprivate booleancheckingDisabledprivate static intDNS_MIN_HEADER_SIZEprivate static intFLAGS_OFFSETprivate static intFLAGS_SIZEprivate shortidprivate static intID_OFFSETprivate static intID_SIZEprivate shortnsCountprivate static intNSCOUNT_OFFSETprivate static intNSCOUNT_SIZEprivate DnsOpCodeopCodeprivate shortqdCountprivate static intQDCOUNT_OFFSETprivate static intQDCOUNT_SIZEprivate java.util.List<DnsQuestion>questionsprivate DnsRCoderCodeprivate booleanrecursionAvailableprivate booleanrecursionDesiredprivate booleanreservedprivate booleanresponseprivate static longserialVersionUIDprivate booleantruncated
-
Constructor Summary
Constructors Modifier Constructor Description privateDnsHeader(byte[] rawData, int offset, int length)privateDnsHeader(DnsPacket.Builder builder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringbuildString()This method builds the valuetoString()will return.protected intcalcHashCode()This method builds the valuehashCode()will return using the byte arraygetRawData()returns.booleanequals(java.lang.Object obj)Indicates whether some other object is "equal to" this one using return values ofgetRawData().java.util.List<DnsResourceRecord>getAdditionalInfo()shortgetAnCount()intgetAnCountAsInt()java.util.List<DnsResourceRecord>getAnswers()shortgetArCount()intgetArCountAsInt()java.util.List<DnsResourceRecord>getAuthorities()shortgetId()shortgetNsCount()intgetNsCountAsInt()DnsOpCodegetOpCode()shortgetQdCount()intgetQdCountAsInt()java.util.List<DnsQuestion>getQuestions()protected java.util.List<byte[]>getRawFields()Returns a list of byte arrays which represents this header's fields.DnsRCodegetrCode()booleangetReservedBit()booleanisAuthenticData()booleanisAuthoritativeAnswer()booleanisCheckingDisabled()booleanisRecursionAvailable()booleanisRecursionDesired()booleanisResponse()booleanisTruncated()intlength()Returns the header length in bytes.-
Methods inherited from class org.pcap4j.packet.AbstractPacket.AbstractHeader
buildHexString, buildRawData, calcLength, getRawData, hashCode, toHexString, toString
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
ID_OFFSET
private static final int ID_OFFSET
- See Also:
- Constant Field Values
-
ID_SIZE
private static final int ID_SIZE
- See Also:
- Constant Field Values
-
FLAGS_OFFSET
private static final int FLAGS_OFFSET
- See Also:
- Constant Field Values
-
FLAGS_SIZE
private static final int FLAGS_SIZE
- See Also:
- Constant Field Values
-
QDCOUNT_OFFSET
private static final int QDCOUNT_OFFSET
- See Also:
- Constant Field Values
-
QDCOUNT_SIZE
private static final int QDCOUNT_SIZE
- See Also:
- Constant Field Values
-
ANCOUNT_OFFSET
private static final int ANCOUNT_OFFSET
- See Also:
- Constant Field Values
-
ANCOUNT_SIZE
private static final int ANCOUNT_SIZE
- See Also:
- Constant Field Values
-
NSCOUNT_OFFSET
private static final int NSCOUNT_OFFSET
- See Also:
- Constant Field Values
-
NSCOUNT_SIZE
private static final int NSCOUNT_SIZE
- See Also:
- Constant Field Values
-
ARCOUNT_OFFSET
private static final int ARCOUNT_OFFSET
- See Also:
- Constant Field Values
-
ARCOUNT_SIZE
private static final int ARCOUNT_SIZE
- See Also:
- Constant Field Values
-
DNS_MIN_HEADER_SIZE
private static final int DNS_MIN_HEADER_SIZE
- See Also:
- Constant Field Values
-
id
private final short id
-
response
private final boolean response
-
opCode
private final DnsOpCode 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
private final DnsRCode rCode
-
qdCount
private final short qdCount
-
anCount
private final short anCount
-
nsCount
private final short nsCount
-
arCount
private final short arCount
-
questions
private final java.util.List<DnsQuestion> questions
-
answers
private final java.util.List<DnsResourceRecord> answers
-
authorities
private final java.util.List<DnsResourceRecord> authorities
-
additionalInfo
private final java.util.List<DnsResourceRecord> additionalInfo
-
-
Constructor Detail
-
DnsHeader
private DnsHeader(byte[] rawData, int offset, int length) throws IllegalRawDataException- Throws:
IllegalRawDataException
-
DnsHeader
private DnsHeader(DnsPacket.Builder builder)
-
-
Method Detail
-
getId
public short getId()
- Returns:
- id
-
isResponse
public boolean isResponse()
- Returns:
- true if the QR bit is set to 1; false otherwise.
-
getOpCode
public DnsOpCode 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
public DnsRCode 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
public java.util.List<DnsQuestion> getQuestions()
- Returns:
- questions
-
getAnswers
public java.util.List<DnsResourceRecord> getAnswers()
- Returns:
- answers
-
getAuthorities
public java.util.List<DnsResourceRecord> getAuthorities()
- Returns:
- authorities
-
getAdditionalInfo
public java.util.List<DnsResourceRecord> getAdditionalInfo()
- Returns:
- additionalInfo
-
getRawFields
protected java.util.List<byte[]> 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
protected java.lang.String 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
public boolean equals(java.lang.Object obj)
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
-
-