pub unsafe extern "C" fn otDnsRecordResponseGetRecordInfo(
aResponse: *const otDnsRecordResponse,
aIndex: u16,
aRecordInfo: *mut otDnsRecordInfo,
) -> otError
Expand description
Reads the records from a DNS query response.
MUST only be used from otDnsRecordCallback
.
The response may include multiple records. @p aIndex can be used to iterate through the list. Index zero gets the
first record and so on. When we reach the end of the list, OT_ERROR_NOT_FOUND
is returned.
Upon successful retrieval (OT_ERROR_NONE
):
mRecordLength
is set to the actual length of the record’s data.- The data is copied into
mDataBuffer
(if notNULL
) up to its capacity specified bymDataBufferSize
. mDataBufferSize
is then updated to reflect the number of bytes actually written intomDataBuffer
.
If the retrieved record type is NS, CNAME, SOA, PTR, MX, RP, AFSDB, RT, PX, SRV, KX, DNAME, or NSEC, the record
data in the received response contains a DNS name which may use DNS name compression. For these specific record
types, the record data is first decompressed such that it contains the full uncompressed DNS name. This decompressed
data is then provided in mDataBuffer
, and mRecordDataLength
will indicate the length of this decompressed data.
For all other record types, the record data is read and provided as it appears in the received response message.
@param[in] aResponse A pointer to the response.
@param[in] aIndex The record index to retrieve.
@param[out] aRecordInfo A pointer to a otDnsRecordInfo
to populate with read record info.
@retval OT_ERROR_NONE The record was read successfully.
@retval OT_ERROR_NOT_FOUND No record in @p aResponse at @p aIndex.
@retval OT_ERROR_PARSE Could not parse the records in the @p aResponse.
@retval OT_ERROR_NO_BUFS The record name does not fit in the provided mNameBufferSize
in @p aRecordInfo, or
failed to allocate buffer to decompress a compressed DNS name.