#include <DnsResourceData.h>
A class that represents DNS RR mail exchange (MX) data, used in DNS RRs of type DNS_TYPE_MX
◆ MxDnsResourceData() [1/2]
pcpp::MxDnsResourceData::MxDnsResourceData |
( |
uint8_t * |
dataPtr, |
|
|
size_t |
dataLen, |
|
|
IDnsResource * |
dnsResource |
|
) |
| |
A c'tor for this class
- Parameters
-
[in] | dataPtr | A byte array that contains the raw MX data (as written in the DNS packet) |
[in] | dataLen | The byte array size |
[in] | dnsResource | A pointer to a DNS resource object where this DNS RR data will be stored |
◆ MxDnsResourceData() [2/2]
pcpp::MxDnsResourceData::MxDnsResourceData |
( |
const uint16_t & |
preference, |
|
|
const std::string & |
mailExchange |
|
) |
| |
A c'tor for this class
- Parameters
-
[in] | preference | The MX preference value to store in this object |
[in] | mailExchange | The MX hostname value to store in this object. It's possible to include a pointer to another string in the DNS layer (as explained here: http://www.zytrax.com/books/dns/ch15/#name). These pointers are often used to reduce the DNS packet size and avoid unnecessary duplications. The way to include pointers in the hostname string is to use the following format: 'some.domain.#{offset}' where '#{offset}' is the offset from the start of the DNS layer. For example: if the string 'yahoo.com' already appears in offset 12 in the packet and you want to set the DNS RR data as 'my.subdomain.yahoo.com' you may use the following string: 'my.subdomain.#12'. This will result in writing 'my.subdomain' and a pointer to offset 12 |
◆ getMxData()
MxData pcpp::MxDnsResourceData::getMxData |
( |
| ) |
|
|
inline |
- Returns
- The MX data stored in this object
◆ operator==()
Equality operator overload for this class that compares the MX data stored in each object
- Parameters
-
[in] | other | The object to compare with |
- Returns
- True if MX data is the same in both objects, meaning both preference and MX hostname are the same, false otherwise
◆ setMxData()
void pcpp::MxDnsResourceData::setMxData |
( |
uint16_t |
preference, |
|
|
std::string |
mailExchange |
|
) |
| |
Set the MX data stored in this object
- Parameters
-
[in] | preference | The MX preference value to store in this object |
[in] | mailExchange | The MX hostname value to store in this object |
◆ toByteArr()
bool pcpp::MxDnsResourceData::toByteArr |
( |
uint8_t * |
arr, |
|
|
size_t & |
arrLength, |
|
|
IDnsResource * |
dnsResource |
|
) |
| |
|
virtual |
Convert the DNS RR data into a byte array
- Parameters
-
[out] | arr | A pointer to a pre-allocated byte array where the result will be written to |
[out] | arrLength | A reference to a 2-byte number where the result array length will be written to |
[in] | dnsResource | A pointer to a DNS resource object where this DNS RR data will be stored |
- Returns
- True if the DNS RR data was successfully converted into a byte array and written to the given array or false if stored DNS RR data is invalid or if it could not be written to the given array
Implements pcpp::IDnsResourceData.
◆ toString()
std::string pcpp::MxDnsResourceData::toString |
( |
| ) |
|
|
virtual |
A string representation of the MX data stored in this object. The string format is as follows: 'pref: {preference_value}; mx: {mail_exchange_hostname_value}'
Implements pcpp::IDnsResourceData.