diff --git a/src/core/net/dns_types.hpp b/src/core/net/dns_types.hpp index 753dc2f46..5f8ee51b4 100644 --- a/src/core/net/dns_types.hpp +++ b/src/core/net/dns_types.hpp @@ -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. *