pub unsafe extern "C" fn otDnsServiceResponseGetServiceInfo(
    aResponse: *const otDnsServiceResponse,
    aServiceInfo: *mut otDnsServiceInfo
) -> otError
Expand description

Gets info for a service instance from a DNS service instance resolution response.

MUST only be used from a otDnsServiceCallback triggered from otDnsClientResolveService() or otDnsClientResolveServiceAndHostAddress().

When this is is used from a otDnsClientResolveService() callback, the DNS response from server/resolver may include AAAA records in its Additional Data section for the host name associated with the service instance that is resolved. This is a SHOULD and not a MUST requirement so servers/resolvers are not required to provide this. This function attempts to parse AAAA record(s) if included in the response. If it is not included mHostAddress is set to all zeros (unspecified address). To also resolve the host address, user can use the DNS client API function otDnsClientResolveServiceAndHostAddress() which will perform service resolution followed up by a host name address resolution query (when AAAA records are not provided by server/resolver in the SRV query response).

  • If a matching SRV record is found in @p aResponse, @p aServiceInfo is updated.
  • If no matching SRV record is found, OT_ERROR_NOT_FOUND is returned unless the query config for this query used OT_DNS_SERVICE_MODE_TXT for mServiceMode (meaning the request was only for TXT record). In this case, we still try to parse the SRV record from Additional Data Section of response (in case server provided the info).
  • 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().

@param[in] aResponse A pointer to the response. @param[out] aServiceInfo A ServiceInfo to output the service instance information (MUST NOT be NULL).

@retval OT_ERROR_NONE The service instance info was read. @p aServiceInfo is updated. @retval OT_ERROR_NOT_FOUND Could not find a required record in @p aResponse. @retval OT_ERROR_NO_BUFS The host name and/or TXT data could not fit in the given buffers. @retval OT_ERROR_PARSE Could not parse the records in the @p aResponse.