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);
426 std::string toString()
const;
435 static inline bool isDnsPort(uint16_t port);
445 static inline bool isDataValid(
const uint8_t* data,
size_t dataLen,
bool dnsOverTcp =
false);
448 DnsLayer(uint8_t* data,
size_t dataLen,
Layer* prevLayer,
Packet* packet,
size_t offsetAdjustment);
449 explicit DnsLayer(
size_t offsetAdjustment);
457 uint16_t m_OffsetAdjustment;
459 size_t getBasicHeaderSize();
460 void init(
size_t offsetAdjustment,
bool callParseResource);
461 void initNewLayer(
size_t offsetAdjustment);
466 using Layer::extendLayer;
467 bool extendLayer(
int offsetInLayer,
size_t numOfBytesToExtend,
IDnsResource* resource);
469 using Layer::shortenLayer;
470 bool shortenLayer(
int offsetInLayer,
size_t numOfBytesToShorten,
IDnsResource* resource);
472 IDnsResource* getResourceByName(
IDnsResource* startFrom,
size_t resourceCount,
const std::string& name,
bool exactMatch)
const;
474 void parseResources();
507 :
DnsLayer(data, dataLen, prevLayer, packet, sizeof(uint16_t)) {}
523 uint16_t getTcpMessageLength();
529 void setTcpMessageLength(uint16_t value);
537 void computeCalculateFields();
558 size_t minSize =
sizeof(
dnshdr) + (dnsOverTcp ?
sizeof(uint16_t) : 0);
559 return data && dataLen >= minSize;
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:333
DnsOverTcpLayer(const DnsOverTcpLayer &other)
Definition: DnsLayer.h:518
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:428
Definition: ProtocolType.h:348
DnsOverTcpLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: DnsLayer.h:506
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:556
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:424
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:495
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:512
static bool isDnsPort(uint16_t port)
Definition: DnsLayer.h:543
uint16_t recursionAvailable
Definition: DnsLayer.h:31