1 #ifndef PACKETPP_DNS_LAYER 2 #define PACKETPP_DNS_LAYER 28 #if (BYTE_ORDER == LITTLE_ENDIAN) 50 #elif (BYTE_ORDER == BIG_ENDIAN) 138 dnshdr* getDnsHeader()
const;
147 DnsQuery* getQuery(
const std::string& name,
bool exactMatch)
const;
164 size_t getQueryCount()
const;
190 bool removeQuery(
const std::string& queryNameToRemove,
bool exactMatch);
197 bool removeQuery(
DnsQuery* queryToRemove);
206 DnsResource* getAnswer(
const std::string& name,
bool exactMatch)
const;
223 size_t getAnswerCount()
const;
253 bool removeAnswer(
const std::string& answerNameToRemove,
bool exactMatch);
270 DnsResource* getAuthority(
const std::string& name,
bool exactMatch)
const;
287 size_t getAuthorityCount()
const;
317 bool removeAuthority(
const std::string& authorityNameToRemove,
bool exactMatch);
324 bool removeAuthority(
DnsResource* authorityToRemove);
335 DnsResource* getAdditionalRecord(
const std::string& name,
bool exactMatch)
const;
353 size_t getAdditionalRecordCount()
const;
399 bool removeAdditionalRecord(
const std::string& additionalRecordNameToRemove,
bool exactMatch);
406 bool removeAdditionalRecord(
DnsResource* additionalRecordToRemove);
427 std::string toString()
const;
436 static inline bool isDnsPort(uint16_t port);
446 static inline bool isDataValid(
const uint8_t* data,
size_t dataLen,
bool dnsOverTcp =
false);
449 DnsLayer(uint8_t* data,
size_t dataLen,
Layer* prevLayer,
Packet* packet,
size_t offsetAdjustment);
458 uint16_t m_OffsetAdjustment;
460 size_t getBasicHeaderSize();
461 void init(
size_t offsetAdjustment,
bool callParseResource);
462 void initNewLayer(
size_t offsetAdjustment);
467 using Layer::extendLayer;
468 bool extendLayer(
int offsetInLayer,
size_t numOfBytesToExtend,
IDnsResource* resource);
470 using Layer::shortenLayer;
471 bool shortenLayer(
int offsetInLayer,
size_t numOfBytesToShorten,
IDnsResource* resource);
473 IDnsResource* getResourceByName(
IDnsResource* startFrom,
size_t resourceCount,
const std::string& name,
bool exactMatch)
const;
475 void parseResources();
508 :
DnsLayer(data, dataLen, prevLayer, packet, sizeof(uint16_t)) {}
524 uint16_t getTcpMessageLength();
530 void setTcpMessageLength(uint16_t value);
538 void computeCalculateFields();
559 size_t minSize =
sizeof(
dnshdr) + (dnsOverTcp ?
sizeof(uint16_t) : 0);
560 return dataLen >= minSize;
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:263
DnsOverTcpLayer(const DnsOverTcpLayer &other)
Definition: DnsLayer.h:519
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:429
Definition: ProtocolType.h:278
DnsOverTcpLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: DnsLayer.h:507
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:557
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:419
virtual void computeCalculateFields()
Definition: DnsLayer.h:425
uint16_t recursionDesired
Definition: DnsLayer.h:31
DnsResourceType
Definition: DnsLayerEnums.h:145
void parseNextLayer()
Definition: DnsLayer.h:413
Definition: DnsLayer.h:24
uint16_t transactionID
Definition: DnsLayer.h:27
Definition: DnsLayer.h:496
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:513
static bool isDnsPort(uint16_t port)
Definition: DnsLayer.h:544
uint16_t recursionAvailable
Definition: DnsLayer.h:31