esp_openthread_dns64.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include "esp_openthread.h"
  8. #include "lwip/netdb.h"
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. // The network data change callback sets the dns server address of index 0, while the CLI sets the dns server address of index 1.
  13. #define OPENTHREAD_DNS_SERVER_INDEX 0
  14. /**
  15. * @brief This function initiizes the dns64 client.
  16. *
  17. * @return
  18. * - ESP_OK on success
  19. * - ESP_FAIL if OpenThread state changed callback fails to be registered
  20. *
  21. */
  22. esp_err_t esp_openthread_dns64_client_init(void);
  23. /**
  24. * @brief This function acquires the DNS server address.
  25. *
  26. * @param[out] dnsserver_addr The dns server address.
  27. *
  28. * @return
  29. * - ESP_OK on sussess
  30. * - ESP_ERR_INVALID_ARG if dnsserver_addr is NULL
  31. * - ESP_ERR_INVALID_STATE if dns sever address not available
  32. */
  33. esp_err_t esp_openthread_get_dnsserver_addr(ip6_addr_t *dnsserver_addr);
  34. /**
  35. * @brief This function acquires the NAT64 prefix in the Thread network.
  36. *
  37. * @param[out] nat64_prefix The NAT64 prefix output.
  38. *
  39. * @return
  40. * - ESP_OK on success
  41. * - ESP_ERR_NOT_FOUND if NAT64 prefix available
  42. *
  43. */
  44. esp_err_t esp_openthread_get_nat64_prefix(ip6_addr_t *nat64_prefix);
  45. /**
  46. * @brief The alternative function for gethostbyname and adds the NAT64 prefix.
  47. *
  48. */
  49. struct hostent *esp_openthread_gethostbyname_dns64(const char *name);
  50. /**
  51. * @brief The alternative function for getaddrinfo and adds the NAT64 prefix.
  52. *
  53. */
  54. int esp_openthread_getaddrinfo_dns64(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res);
  55. #ifdef __cplusplus
  56. }
  57. #endif