Package org.pcap4j.packet
Class DnsPacket.DnsHeader
- 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 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
- Author:
- Kaito Yamada
- See Also:
- RFC 1035, RFC 2535, Serialized Form
-
-
Method Summary
Modifier and Type Method Description protected java.lang.String
buildString()
This method builds the valuetoString()
will return.protected int
calcHashCode()
This method builds the valuehashCode()
will return using the byte arraygetRawData()
returns.boolean
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one using return values ofgetRawData()
.java.util.List<DnsResourceRecord>
getAdditionalInfo()
short
getAnCount()
int
getAnCountAsInt()
java.util.List<DnsResourceRecord>
getAnswers()
short
getArCount()
int
getArCountAsInt()
java.util.List<DnsResourceRecord>
getAuthorities()
short
getId()
short
getNsCount()
int
getNsCountAsInt()
DnsOpCode
getOpCode()
short
getQdCount()
int
getQdCountAsInt()
java.util.List<DnsQuestion>
getQuestions()
protected java.util.List<byte[]>
getRawFields()
Returns a list of byte arrays which represents this header's fields.DnsRCode
getrCode()
boolean
getReservedBit()
boolean
isAuthenticData()
boolean
isAuthoritativeAnswer()
boolean
isCheckingDisabled()
boolean
isRecursionAvailable()
boolean
isRecursionDesired()
boolean
isResponse()
boolean
isTruncated()
int
length()
Returns the header length in bytes.-
Methods inherited from class org.pcap4j.packet.AbstractPacket.AbstractHeader
buildHexString, buildRawData, calcLength, getRawData, hashCode, toHexString, toString
-
-
-
-
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.AbstractHeader
Returns a list of byte arrays which represents this header's fields. This method is called bycalcLength()
andbuildRawData()
.- Specified by:
getRawFields
in classAbstractPacket.AbstractHeader
- Returns:
- a list of byte arrays which represents this header's fields
-
length
public int length()
Description copied from class:AbstractPacket.AbstractHeader
Returns 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:
length
in interfacePacket.Header
- Overrides:
length
in 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.AbstractHeader
This method builds the valuetoString()
will return.- Overrides:
buildString
in classAbstractPacket.AbstractHeader
- Returns:
- a string representation of this object
-
equals
public boolean equals(java.lang.Object obj)
Description copied from class:AbstractPacket.AbstractHeader
Indicates 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:
equals
in classAbstractPacket.AbstractHeader
-
calcHashCode
protected int calcHashCode()
Description copied from class:AbstractPacket.AbstractHeader
This method builds the valuehashCode()
will return using the byte arraygetRawData()
returns. This method may be better to be overridden for performance reason.- Overrides:
calcHashCode
in classAbstractPacket.AbstractHeader
- Returns:
- a calculated hash code value for the object
-
-