TuyaOS
uni_network.h
浏览该文件的文档.
1
25#ifndef __TUYA_BASE_UNI_DNS_CACHE_H__
26#define __TUYA_BASE_UNI_DNS_CACHE_H__
27
28#include "tuya_iot_config.h"
29#include "tuya_cloud_types.h"
30#include "tuya_hal_network.h"
31
32
33#ifdef __cplusplus
34 extern "C" {
35#endif
36
37
42#define MAX_DOMAIN_NAME_LEN 128
43
48#if defined(TLS_MODE) && (TLS_MODE!=TLS_DISABLE)
49#if defined(TLS_MODE) && ( (TLS_MODE==TLS_TUYA_PSK_ONLY) || (TLS_MODE==TLS_TUYA_ECC_PSK) )
50// TLS_MODE==TLS_TUYA_PSK_ONLY or TLS_MODE==TLS_TUYA_ECC_PSK
51#define HTTP_DNS_SERVER_DOMAIN "h3.iot-dns.com"
52#define HTTP_DNS_SERVER_DOMAIN_WE "h3-we.iot-dns.com"
53#elif defined(TLS_MODE) && (TLS_MODE==TLS_TUYA_ECC_CLIENT_AUTH)
54// TLS_MODE==TLS_TUYA_ECC_CLIENT_AUTH
55#define HTTP_DNS_SERVER_DOMAIN "h4.iot-dns.com"
56#define HTTP_DNS_SERVER_DOMAIN_WE "h4-we.iot-dns.com"
57#else
58// TLS_MODE==TLS_TUYA_PSK_ONLY or TLS_MODE==TLS_TUYA_ECC_ONLY_NOSTRIP
59#define HTTP_DNS_SERVER_DOMAIN "h2.iot-dns.com"
60#define HTTP_DNS_SERVER_DOMAIN_WE "h2-we.iot-dns.com"
61#endif
62#else
63// TLS_MODE==DISABLE
64#error "tls mode must be set."
65#endif
66
71typedef UINT_T REGION_E;
72#define E_REGION_DYNAMIC 0 // no fixed region
73#define E_REGION_CN 1 // china region
74#define E_REGION_EU 2 // european region
75#define E_REGION_US 3 // american region
76#define E_REGION_UE 4 // west american region
77#define E_REGION_IN 5 // indian region
78#define E_REGION_WE 6 // west european region
79#define E_REGION_MAX 7 // region max
80
85typedef UINT_T TY_DNS_PRIO_T;
86#define DNS_PRIO_REGION 0 // default priority, use the dns server of current region
87#define DNS_PRIO_RANDOM 1 // select a random dns server of the regions except current region
88#define DNS_PRIO_SYSTEM 2 // use the system dns service of the router
89
94typedef struct
95{
96 REGION_E region; // the region of the DNS entry
97 CHAR_T *domain;// the domain of the DNS entry
98 UNW_IP_ADDR_T ip; // the ip address of the DNS entry
100
108OPERATE_RET unw_gethostbyname(CONST CHAR_T *domain, UNW_IP_ADDR_T *addr);
109
120OPERATE_RET unw_connect_to_domain(INT_T *sockfd, CHAR_T *hostname, UINT16_T port, UINT_T retry_cnt, UINT_T timeout);
121
127OPERATE_RET unw_init_dns_cache(VOID);
128
134OPERATE_RET unw_clear_all_dns_cache(VOID);
135
142OPERATE_RET unw_clear_dns_cache(CONST CHAR_T *domain);
143
151OPERATE_RET unw_add_dns_cache(CONST CHAR_T *domain, CONST UNW_IP_ADDR_T ip);
152
159OPERATE_RET unm_set_dns_region(REGION_E region);
160
168
175
182
183
184
185#ifdef __cplusplus
186}
187#endif
188
189#endif // __TUYA_BASE_UNI_DNS_CACHE_H__
190
DNS entry info
Definition: uni_network.h:95
Common process - Initialization
OPERATE_RET unw_clear_dns_cache(CONST CHAR_T *domain)
clear the specific domain dns cache
OPERATE_RET unm_set_dns_cache_priority(TY_DNS_PRIO_T dns_prio)
set the dns priority
OPERATE_RET unw_gethostbyname(CONST CHAR_T *domain, UNW_IP_ADDR_T *addr)
get the domain ip address info by the domain name
UINT_T REGION_E
each TLS MODE have specific iot-dns domain name
Definition: uni_network.h:71
OPERATE_RET unm_set_dns_region(REGION_E region)
set the dns current region
OPERATE_RET unw_clear_all_dns_cache(VOID)
clean all dynamic dns cache
TY_DNS_PRIO_T unm_get_dns_cache_priority(VOID)
get the dns current priority
OPERATE_RET unw_init_dns_cache(VOID)
init the dns module
VOID unm_lower_dns_cache_priority(VOID)
decrease the dns current priority
UINT_T TY_DNS_PRIO_T
DNS priority
Definition: uni_network.h:85
OPERATE_RET unw_connect_to_domain(INT_T *sockfd, CHAR_T *hostname, UINT16_T port, UINT_T retry_cnt, UINT_T timeout)
connect to a domain with specific tcp port
OPERATE_RET unw_add_dns_cache(CONST CHAR_T *domain, CONST UNW_IP_ADDR_T ip)
add dns information to dynamic dns cache