1 #ifndef PACKETPP_DNS_LAYER 2 #define PACKETPP_DNS_LAYER 7 #if defined(WIN32) || defined(WINx64) || defined(PCAPPP_MINGW_ENV) 32 #if (BYTE_ORDER == LITTLE_ENDIAN) 54 #elif (BYTE_ORDER == BIG_ENDIAN) 234 size_t m_OffsetInLayer;
236 std::string m_DecodedName;
238 uint8_t* m_ExternalRawData;
244 size_t decodeName(
const char* encodedName,
char* result,
int iteration = 1);
245 void encodeName(
const std::string& decodedName,
char* result,
size_t& resultLen);
247 inline IDnsResource* getNextResource() {
return m_NextResource; }
248 inline void setNexResource(
IDnsResource* next) { m_NextResource = next; }
250 uint8_t* getRawData();
252 void setDnsLayer(
DnsLayer* dnsLayer,
size_t offsetInLayer);
297 std::string
getName() {
return m_DecodedName; }
304 bool setName(
const std::string& newName);
338 virtual size_t getSize() {
return m_NameLength + 2*
sizeof(uint16_t); }
370 void setTTL(uint32_t newTTL);
401 bool setData(
const std::string& dataAsString);
520 bool removeQuery(
const std::string& queryNameToRemove,
bool exactMatch);
581 bool removeAnswer(
const std::string& answerNameToRemove,
bool exactMatch);
643 bool removeAuthority(
const std::string& authorityNameToRemove,
bool exactMatch);
766 using Layer::extendLayer;
767 bool extendLayer(
int offsetInLayer,
size_t numOfBytesToExtend,
IDnsResource* resource);
769 using Layer::shortenLayer;
770 bool shortenLayer(
int offsetInLayer,
size_t numOfBytesToShorten,
IDnsResource* resource);
772 IDnsResource* getResourceByName(
IDnsResource* startFrom,
size_t resourceCount,
const std::string& name,
bool exactMatch);
774 void parseResources();
777 uint32_t ttl,
const std::string& data);
virtual size_t getSize()=0
uint16_t numberOfAdditional
Definition: DnsLayer.h:84
uint16_t authenticData
Definition: DnsLayer.h:35
Definition: DnsLayer.h:95
Definition: DnsLayer.h:263
Definition: DnsLayer.h:97
Definition: DnsLayer.h:187
uint16_t checkingDisabled
Definition: DnsLayer.h:35
void setTTL(uint32_t newTTL)
Definition: DnsLayer.h:169
Definition: DnsLayer.h:159
Definition: DnsLayer.h:131
Definition: DnsLayer.h:195
DnsLayer & operator=(const DnsLayer &other)
Definition: DnsLayer.h:163
Definition: DnsLayer.h:155
Definition: DnsLayer.h:103
Definition: DnsLayer.h:347
Definition: DnsLayer.h:28
void computeCalculateFields()
Definition: DnsLayer.h:746
Definition: DnsLayer.h:211
Definition: DnsLayer.h:133
DnsType
Definition: DnsLayer.h:92
Definition: DnsLayer.h:113
Definition: DnsLayer.h:111
DnsResource * getNextAdditionalRecord(DnsResource *additionalRecord)
Definition: DnsLayer.h:189
bool removeAdditionalRecord(const std::string &additionalRecordNameToRemove, bool exactMatch)
Definition: DnsLayer.h:193
Definition: DnsLayer.h:171
Definition: DnsLayer.h:115
DnsQuery * getFirstQuery()
uint16_t transactionID
Definition: DnsLayer.h:31
DnsResource * getFirstAnswer()
DnsQuery * getNextQuery(DnsQuery *query)
Definition: ProtocolType.h:223
The main namespace for the PcapPlusPlus lib.
Definition: DnsLayer.h:143
Definition: DnsLayer.h:107
DnsResource * getNextAnswer(DnsResource *answer)
Definition: DnsLayer.h:209
Definition: DnsLayer.h:177
DnsClass
Definition: DnsLayer.h:204
DnsQuery * addQuery(const std::string &name, DnsType dnsType, DnsClass dnsClass)
Definition: DnsLayer.h:325
dnshdr * getDnsHeader()
Definition: DnsLayer.h:468
DnsResource * getFirstAdditionalRecord()
virtual size_t getSize()
Definition: DnsLayer.h:418
Definition: DnsLayer.h:151
size_t getHeaderLen()
Definition: DnsLayer.h:741
Definition: DnsLayer.h:135
OsiModelLayer
Definition: ProtocolType.h:208
void setCustomDnsClass(uint16_t customValue)
Definition: DnsLayer.h:139
uint16_t getCustomDnsClass()
Definition: DnsLayer.h:197
Definition: DnsLayer.h:127
DnsResource * addAdditionalRecord(const std::string &name, DnsType dnsType, DnsClass dnsClass, uint32_t ttl, const std::string &data)
Definition: DnsLayer.h:191
Definition: DnsLayer.h:429
void setDnsType(DnsType newType)
Definition: DnsLayer.h:109
Definition: DnsLayer.h:161
ResourceType
Definition: DnsLayer.h:258
DnsResource * addAnswer(const std::string &name, DnsType dnsType, DnsClass dnsClass, uint32_t ttl, const std::string &data)
virtual size_t getSize()
Definition: DnsLayer.h:338
std::string getDataAsString()
bool removeAnswer(const std::string &answerNameToRemove, bool exactMatch)
Definition: DnsLayer.h:185
void setDnsClass(DnsClass newClass)
size_t getAuthorityCount()
Definition: DnsLayer.h:117
Definition: DnsLayer.h:121
Definition: DnsLayer.h:149
Definition: DnsLayer.h:105
void parseNextLayer()
Definition: DnsLayer.h:735
virtual ResourceType getType()
Definition: DnsLayer.h:339
uint16_t recursionDesired
Definition: DnsLayer.h:35
Definition: DnsLayer.h:129
Definition: DnsLayer.h:153
Definition: DnsLayer.h:183
uint16_t recursionAvailable
Definition: DnsLayer.h:35
uint16_t numberOfAnswers
Definition: DnsLayer.h:80
Definition: DnsLayer.h:165
bool setName(const std::string &newName)
Definition: DnsLayer.h:265
Definition: DnsLayer.h:157
uint16_t truncation
Definition: DnsLayer.h:35
bool removeQuery(const std::string &queryNameToRemove, bool exactMatch)
Definition: DnsLayer.h:101
Definition: DnsLayer.h:99
Definition: DnsLayer.h:147
Definition: DnsLayer.h:141
Definition: DnsLayer.h:207
Definition: DnsLayer.h:145
DnsResource * getFirstAuthority()
std::string getName()
Definition: DnsLayer.h:297
virtual ResourceType getType()=0
DnsResource * addAuthority(const std::string &name, DnsType dnsType, DnsClass dnsClass, uint32_t ttl, const std::string &data)
bool setData(const std::string &dataAsString)
uint16_t responseCode
Definition: DnsLayer.h:35
static const std::map< uint16_t, bool > * getDNSPortMap()
OsiModelLayer getOsiModelLayer()
Definition: DnsLayer.h:750
DnsResource * getAuthority(const std::string &name, bool exactMatch)
Definition: DnsLayer.h:167
DnsResource * getAdditionalRecord(const std::string &name, bool exactMatch)
Definition: DnsLayer.h:213
uint16_t queryOrResponse
Definition: DnsLayer.h:35
uint16_t opcode
Definition: DnsLayer.h:35
Definition: DnsLayer.h:261
Definition: DnsLayer.h:175
Definition: DnsLayer.h:227
Definition: DnsLayer.h:173
size_t getAdditionalRecordCount()
Definition: DnsLayer.h:125
Definition: DnsLayer.h:181
uint16_t zero
Definition: DnsLayer.h:35
bool removeAuthority(const std::string &authorityNameToRemove, bool exactMatch)
uint16_t numberOfQuestions
Definition: DnsLayer.h:78
uint16_t numberOfAuthority
Definition: DnsLayer.h:82
virtual ResourceType getType()
Definition: DnsLayer.h:419
DnsQuery * getQuery(const std::string &name, bool exactMatch)
uint16_t authoritativeAnswer
Definition: DnsLayer.h:35
DnsResource * getAnswer(const std::string &name, bool exactMatch)
Definition: DnsLayer.h:123
Definition: DnsLayer.h:215
Definition: DnsLayer.h:267
Definition: DnsLayer.h:179
Definition: DnsLayer.h:137
DnsResource * getNextAuthority(DnsResource *authority)
Definition: DnsLayer.h:119