[dns-types] Add Dns::ARecord for A records (#6404)

This commit is contained in:
Abtin Keshavarzian
2021-04-06 15:36:19 -07:00
committed by GitHub
parent 77d3af396c
commit 0ecae494dc
+46
View File
@@ -44,6 +44,7 @@
#include "common/equatable.hpp"
#include "common/message.hpp"
#include "crypto/ecdsa.hpp"
#include "net/ip4_address.hpp"
#include "net/ip6_address.hpp"
namespace ot {
@@ -1497,6 +1498,51 @@ private:
} OT_TOOL_PACKED_END;
/**
* This class implements Resource Record body format of A type.
*
*/
OT_TOOL_PACKED_BEGIN
class ARecord : public ResourceRecord
{
public:
enum : uint16_t
{
kType = kTypeA, ///< The A record type.
};
/**
* This method initializes the A Resource Record by setting its type, class, and length.
*
* Other record fields (TTL, address) remain unchanged/uninitialized.
*
*/
void Init(void)
{
ResourceRecord::Init(kTypeA);
SetLength(sizeof(Ip4::Address));
}
/**
* This method sets the IPv4 address of the resource record.
*
* @param[in] aAddress The IPv4 address of the resource record.
*
*/
void SetAddress(const Ip4::Address &aAddress) { mAddress = aAddress; }
/**
* This method returns the reference to IPv4 address of the resource record.
*
* @returns The reference to IPv4 address of the resource record.
*
*/
const Ip4::Address &GetAddress(void) const { return mAddress; }
private:
Ip4::Address mAddress; // IPv4 Address of A Resource Record.
} OT_TOOL_PACKED_END;
/**
* This class implements Resource Record body format of CNAME type.
*