1 #ifndef PACKETPP_DNS_LAYER 2 #define PACKETPP_DNS_LAYER 28 #if (BYTE_ORDER == LITTLE_ENDIAN) 50 #elif (BYTE_ORDER == BIG_ENDIAN) 135 dnshdr* getDnsHeader()
const;
144 DnsQuery* getQuery(
const std::string& name,
bool exactMatch)
const;
161 size_t getQueryCount()
const;
187 bool removeQuery(
const std::string& queryNameToRemove,
bool exactMatch);
194 bool removeQuery(
DnsQuery* queryToRemove);
203 DnsResource* getAnswer(
const std::string& name,
bool exactMatch)
const;
220 size_t getAnswerCount()
const;
250 bool removeAnswer(
const std::string& answerNameToRemove,
bool exactMatch);
267 DnsResource* getAuthority(
const std::string& name,
bool exactMatch)
const;
284 size_t getAuthorityCount()
const;
314 bool removeAuthority(
const std::string& authorityNameToRemove,
bool exactMatch);
321 bool removeAuthority(
DnsResource* authorityToRemove);
332 DnsResource* getAdditionalRecord(
const std::string& name,
bool exactMatch)
const;
350 size_t getAdditionalRecordCount()
const;
396 bool removeAdditionalRecord(
const std::string& additionalRecordNameToRemove,
bool exactMatch);
403 bool removeAdditionalRecord(
DnsResource* additionalRecordToRemove);
423 std::string toString()
const;
431 static inline bool isDnsPort(uint16_t port);
441 static inline bool isDataValid(
const uint8_t* data,
size_t dataLen,
bool dnsOverTcp =
false);
444 DnsLayer(uint8_t* data,
size_t dataLen,
Layer* prevLayer,
Packet* packet,
size_t offsetAdjustment);
453 uint16_t m_OffsetAdjustment;
455 size_t getBasicHeaderSize();
456 void init(
size_t offsetAdjustment,
bool callParseResource);
457 void initNewLayer(
size_t offsetAdjustment);
462 using Layer::extendLayer;
463 bool extendLayer(
int offsetInLayer,
size_t numOfBytesToExtend,
IDnsResource* resource);
465 using Layer::shortenLayer;
466 bool shortenLayer(
int offsetInLayer,
size_t numOfBytesToShorten,
IDnsResource* resource);
468 IDnsResource* getResourceByName(
IDnsResource* startFrom,
size_t resourceCount,
const std::string& name,
bool exactMatch)
const;
470 void parseResources();
503 :
DnsLayer(data, dataLen, prevLayer, packet, sizeof(uint16_t)) {}
518 uint16_t getTcpMessageLength();
524 void setTcpMessageLength(uint16_t value);
532 void computeCalculateFields();
553 size_t minSize =
sizeof(
dnshdr) + (dnsOverTcp ?
sizeof(uint16_t) : 0);
554 return dataLen >= minSize;
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:253
DnsOverTcpLayer(const DnsOverTcpLayer &other)
Definition: DnsLayer.h:513
uint16_t authoritativeAnswer
Definition: DnsLayer.h:31
uint16_t opcode
Definition: DnsLayer.h:31
uint16_t numberOfAdditional
Definition: DnsLayer.h:80
OsiModelLayer getOsiModelLayer() const
Definition: DnsLayer.h:425
Definition: ProtocolType.h:268
DnsOverTcpLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: DnsLayer.h:502
uint16_t numberOfAuthority
Definition: DnsLayer.h:78
DnsClass
Definition: DnsLayerEnums.h:127
static bool isDataValid(const uint8_t *data, size_t dataLen, bool dnsOverTcp=false)
Definition: DnsLayer.h:551
Definition: DnsResourceData.h:40
uint16_t responseCode
Definition: DnsLayer.h:31
uint16_t queryOrResponse
Definition: DnsLayer.h:31
uint16_t truncation
Definition: DnsLayer.h:31
DnsType
Definition: DnsLayerEnums.h:15
uint16_t checkingDisabled
Definition: DnsLayer.h:31
Definition: DnsLayer.h:96
uint16_t numberOfAnswers
Definition: DnsLayer.h:76
size_t getHeaderLen() const
Definition: DnsLayer.h:416
virtual void computeCalculateFields()
Definition: DnsLayer.h:421
uint16_t recursionDesired
Definition: DnsLayer.h:31
DnsResourceType
Definition: DnsLayerEnums.h:145
void parseNextLayer()
Definition: DnsLayer.h:410
Definition: DnsLayer.h:24
uint16_t transactionID
Definition: DnsLayer.h:27
Definition: DnsLayer.h:491
uint16_t numberOfQuestions
Definition: DnsLayer.h:74
uint16_t authenticData
Definition: DnsLayer.h:31
Definition: DnsResource.h:150
Definition: DnsResource.h:30
Definition: DnsResource.h:128
uint16_t zero
Definition: DnsLayer.h:31
DnsOverTcpLayer()
Definition: DnsLayer.h:508
static bool isDnsPort(uint16_t port)
Definition: DnsLayer.h:538
uint16_t recursionAvailable
Definition: DnsLayer.h:31