[dns] allow partial read of TXT data and add config for max size in CLI (#8232)

This commit updates `Dns::Client` so that when reading service info
`otDnsServiceInfo` if the received TXT data does not fit in the given
buffer, it is read partially. A new field `mTxtDataTruncated` is added
in `otDnsServiceInfo` to indicate that TXT data was not fully read.

This commit also updates `dns` related commands in CLI so to output
the partially read TXT data and add a new config specifying the max
TXT data size used by CLI.
This commit is contained in:
Abtin Keshavarzian
2022-10-05 15:10:28 -07:00
committed by GitHub
parent c5b4cd7bbc
commit d3e00fbd28
9 changed files with 72 additions and 18 deletions
+4 -1
View File
@@ -323,7 +323,8 @@ typedef struct otDnsServiceInfo
otIp6Address mHostAddress; ///< The host IPv6 address. Set to all zero if not available.
uint32_t mHostAddressTtl; ///< The host address TTL.
uint8_t * mTxtData; ///< Buffer to output TXT data (can be NULL if not needed).
uint16_t mTxtDataSize; ///< On input, size of `mTxtData` buffer. On output `mTxtData` length.
uint16_t mTxtDataSize; ///< On input, size of `mTxtData` buffer. On output number bytes written.
bool mTxtDataTruncated; ///< Indicates if TXT data could not fit in `mTxtDataSize` and was truncated.
uint32_t mTxtDataTtl; ///< The TXT data TTL.
} otDnsServiceInfo;
@@ -408,6 +409,7 @@ otError otDnsBrowseResponseGetServiceInstance(const otDnsBrowseResponse *aRespon
* - If no matching SRV record is found in @p aResponse, `OT_ERROR_NOT_FOUND` is returned.
* - If a matching SRV record is found in @p aResponse, @p aServiceInfo is updated and `OT_ERROR_NONE` is returned.
* - If no matching TXT record is found in @p aResponse, `mTxtDataSize` in @p aServiceInfo is set to zero.
* - If TXT data length is greater than `mTxtDataSize`, it is read partially and `mTxtDataTruncated` is set to true.
* - If no matching AAAA record is found in @p aResponse, `mHostAddress is set to all zero or unspecified address.
* - If there are multiple AAAA records for the host name in @p aResponse, `mHostAddress` is set to the first one. The
* other addresses can be retrieved using `otDnsBrowseResponseGetHostAddress()`.
@@ -537,6 +539,7 @@ otError otDnsServiceResponseGetServiceName(const otDnsServiceResponse *aResponse
* - If no matching SRV record is found in @p aResponse, `OT_ERROR_NOT_FOUND` is returned.
* - If a matching SRV record is found in @p aResponse, @p aServiceInfo is updated and `OT_ERROR_NONE` is returned.
* - If no matching TXT record is found in @p aResponse, `mTxtDataSize` in @p aServiceInfo is set to zero.
* - If TXT data length is greater than `mTxtDataSize`, it is read partially and `mTxtDataTruncated` is set to true.
* - If no matching AAAA record is found in @p aResponse, `mHostAddress is set to all zero or unspecified address.
* - If there are multiple AAAA records for the host name in @p aResponse, `mHostAddress` is set to the first one. The
* other addresses can be retrieved using `otDnsServiceResponseGetHostAddress()`.
+1 -1
View File
@@ -53,7 +53,7 @@ extern "C" {
* @note This number versions both OpenThread platform and user APIs.
*
*/
#define OPENTHREAD_API_VERSION (247)
#define OPENTHREAD_API_VERSION (248)
/**
* @addtogroup api-instance