TuyaOS
|
Common process - Initialization 更多...
#include "tuya_cloud_types.h"
宏定义 | |
#define | TAL_FD_CLR(n, p) tal_net_fd_clear(n, p) |
#define | TAL_FD_ISSET(n, p) tal_net_fd_isset(n,p) |
#define | TAL_FD_SET(n, p) tal_net_fd_set(n, p) |
#define | TAL_FD_ZERO(p) tal_net_fd_zero(p) |
#define | TY_IP6_ADDR_ANY ty_ip6_addr_any |
#define | TY_IPADDR_ANY ty_ip_addr_any |
#define | TY_IPADDR_BROADCAST ty_ip_addr_broadcast |
#define | TY_IPADDR_LOOPBACK ty_ip_addr_loopback |
函数 | |
INT_T | tal_net_accept (CONST INT_T fd, TUYA_IP_ADDR_T *addr, UINT16_T *port) |
Accept the coming socket connection of the server fd 更多... | |
OPERATE_RET | tal_net_add_membership (CONST INT_T fd, TUYA_IP_ADDR_T src_addr, TUYA_IP_ADDR_T group_addr) |
add member ship 更多... | |
CHAR_T * | tal_net_addr2str (TUYA_IP_ADDR_T ipaddr) |
Change ip address to string 更多... | |
TUYA_ERRNO | tal_net_bind (CONST INT_T fd, CONST TUYA_IP_ADDR_T addr, CONST UINT16_T port) |
Bind to network 更多... | |
TUYA_ERRNO | tal_net_close (CONST INT_T fd) |
Close file descriptors 更多... | |
TUYA_ERRNO | tal_net_connect (CONST INT_T fd, CONST TUYA_IP_ADDR_T addr, CONST UINT16_T port) |
Connect to network 更多... | |
TUYA_ERRNO | tal_net_connect_raw (CONST INT_T fd, VOID_T *p_socket, CONST INT_T len) |
Connect to network with raw data 更多... | |
OPERATE_RET | tal_net_disable_nagle (CONST INT_T fd) |
Disable nagle option of socket fd 更多... | |
OPERATE_RET | tal_net_fd_clear (INT_T fd, TUYA_FD_SET_T *fds) |
Clear file descriptor from set 更多... | |
OPERATE_RET | tal_net_fd_isset (INT_T fd, TUYA_FD_SET_T *fds) |
Check file descriptor is in set 更多... | |
OPERATE_RET | tal_net_fd_set (INT_T fd, TUYA_FD_SET_T *fds) |
Add file descriptor to set 更多... | |
OPERATE_RET | tal_net_fd_zero (TUYA_FD_SET_T *fds) |
Clear all file descriptor in set 更多... | |
TUYA_ERRNO | tal_net_get_errno (VOID) |
Get error code of network 更多... | |
INT_T | tal_net_get_nonblock (CONST INT_T fd) |
Get no block file descriptors 更多... | |
OPERATE_RET | tal_net_get_socket_ip (INT_T fd, TUYA_IP_ADDR_T *addr) |
Get ip address by socket fd 更多... | |
OPERATE_RET | tal_net_gethostbyname (IN CONST CHAR_T *domain, IN CONST DNS_MODE_E mode, OUT TUYA_IP_ADDR_T *addr) |
Get address information by domain 更多... | |
OPERATE_RET | tal_net_getsockopt (CONST INT_T fd, CONST TUYA_OPT_LEVEL level, CONST TUYA_OPT_NAME optname, VOID_T *optval, INT_T *optlen) |
Get socket options 更多... | |
TUYA_ERRNO | tal_net_listen (CONST INT_T fd, CONST INT_T backlog) |
Listen to network 更多... | |
TUYA_ERRNO | tal_net_recv (CONST INT_T fd, VOID_T *buf, CONST UINT_T nbytes) |
Receive data from network 更多... | |
INT_T | tal_net_recv_nd_size (CONST INT_T fd, VOID_T *buf, CONST UINT_T buf_size, CONST UINT_T nd_size) |
Receive data from network with need size 更多... | |
TUYA_ERRNO | tal_net_recvfrom (CONST INT_T fd, VOID_T *buf, CONST UINT_T nbytes, TUYA_IP_ADDR_T *addr, UINT16_T *port) |
Receive data from specified server 更多... | |
INT_T | tal_net_select (CONST INT_T maxfd, TUYA_FD_SET_T *readfds, TUYA_FD_SET_T *writefds, TUYA_FD_SET_T *errorfds, CONST UINT_T ms_timeout) |
Get available file descriptors 更多... | |
TUYA_ERRNO | tal_net_send (CONST INT_T fd, CONST VOID_T *buf, CONST UINT_T nbytes) |
Send data to network 更多... | |
TUYA_ERRNO | tal_net_send_to (CONST INT_T fd, CONST VOID_T *buf, CONST UINT_T nbytes, CONST TUYA_IP_ADDR_T addr, CONST UINT16_T port) |
Send data to specified server 更多... | |
OPERATE_RET | tal_net_set_block (CONST INT_T fd, CONST BOOL_T block) |
Set block flag for file descriptors 更多... | |
OPERATE_RET | tal_net_set_broadcast (CONST INT_T fd) |
Enable broadcast option of socket fd 更多... | |
OPERATE_RET | tal_net_set_bufsize (CONST INT_T fd, CONST INT_T buf_size, CONST TUYA_TRANS_TYPE_E type) |
Set buffer_size option of socket fd 更多... | |
OPERATE_RET | tal_net_set_keepalive (INT_T fd, CONST BOOL_T alive, CONST UINT_T idle, CONST UINT_T intr, CONST UINT_T cnt) |
Set keepalive option of socket fd to monitor the connection 更多... | |
OPERATE_RET | tal_net_set_reuse (CONST INT_T fd) |
Enable reuse option of socket fd 更多... | |
OPERATE_RET | tal_net_set_timeout (CONST INT_T fd, CONST INT_T ms_timeout, CONST TUYA_TRANS_TYPE_E type) |
Set timeout option of socket fd 更多... | |
OPERATE_RET | tal_net_sethostname (CONST CHAR_T *hostname) |
Set the system hostname 更多... | |
OPERATE_RET | tal_net_setsockopt (CONST INT_T fd, CONST TUYA_OPT_LEVEL level, CONST TUYA_OPT_NAME optname, CONST VOID_T *optval, CONST INT_T optlen) |
Set socket options 更多... | |
INT_T | tal_net_socket_create (CONST TUYA_PROTOCOL_TYPE_E type) |
Create a tcp/udp socket 更多... | |
INT_T | tal_net_socket_create_v6 (IN CONST TUYA_PROTOCOL_TYPE_E type) |
Create a IPv6 tcp/udp socket 更多... | |
TUYA_IP_ADDR_T | tal_net_str2addr (CONST CHAR_T *ip_str) |
Change ip string to address 更多... | |
常量 | |
const TUYA_IP_ADDR_T | ty_ip6_addr_any |
const TUYA_IP_ADDR_T | ty_ip_addr_any |
const TUYA_IP_ADDR_T | ty_ip_addr_broadcast |
const TUYA_IP_ADDR_T | ty_ip_addr_loopback |
Common process - Initialization
INT_T tal_net_accept | ( | CONST INT_T | fd, |
TUYA_IP_ADDR_T * | addr, | ||
UINT16_T * | port | ||
) |
Accept the coming socket connection of the server fd
[in] | fd | file descriptor |
[in] | addr | address information of server |
[in] | port | port information of server |
OPERATE_RET tal_net_add_membership | ( | CONST INT_T | fd, |
TUYA_IP_ADDR_T | src_addr, | ||
TUYA_IP_ADDR_T | group_addr | ||
) |
add member ship
[in] | fd | socket id |
[in] | src_addr | source addr |
[in] | group_addr | group addr |
CHAR_T * tal_net_addr2str | ( | TUYA_IP_ADDR_T | ipaddr | ) |
Change ip address to string
[in] | ipaddr | ip address |
TUYA_ERRNO tal_net_bind | ( | CONST INT_T | fd, |
CONST TUYA_IP_ADDR_T | addr, | ||
CONST UINT16_T | port | ||
) |
Bind to network
[in] | fd | file descriptor |
[in] | addr | address information of server |
[in] | port | port information of server |
TUYA_ERRNO tal_net_close | ( | CONST INT_T | fd | ) |
Close file descriptors
[in] | fd | file descriptor |
TUYA_ERRNO tal_net_connect | ( | CONST INT_T | fd, |
CONST TUYA_IP_ADDR_T | addr, | ||
CONST UINT16_T | port | ||
) |
Connect to network
[in] | fd | file descriptor |
[in] | addr | address information of server |
[in] | port | port information of server |
TUYA_ERRNO tal_net_connect_raw | ( | CONST INT_T | fd, |
VOID_T * | p_socket, | ||
CONST INT_T | len | ||
) |
Connect to network with raw data
[in] | fd | file descriptor |
[in] | p_socket | raw socket data |
[in] | len | data lenth |
OPERATE_RET tal_net_disable_nagle | ( | CONST INT_T | fd | ) |
Disable nagle option of socket fd
[in] | fd | file descriptor |
OPERATE_RET tal_net_fd_clear | ( | INT_T | fd, |
TUYA_FD_SET_T * | fds | ||
) |
Clear file descriptor from set
[in] | fd | file descriptor |
[in] | fds | set of file descriptor |
OPERATE_RET tal_net_fd_isset | ( | INT_T | fd, |
TUYA_FD_SET_T * | fds | ||
) |
Check file descriptor is in set
[in] | fd | file descriptor |
[in] | fds | set of file descriptor |
OPERATE_RET tal_net_fd_set | ( | INT_T | fd, |
TUYA_FD_SET_T * | fds | ||
) |
Add file descriptor to set
[in] | fd | file descriptor |
[in] | fds | set of file descriptor |
OPERATE_RET tal_net_fd_zero | ( | TUYA_FD_SET_T * | fds | ) |
Clear all file descriptor in set
[in] | fds | set of file descriptor |
TUYA_ERRNO tal_net_get_errno | ( | VOID | ) |
Get error code of network
void |
INT_T tal_net_get_nonblock | ( | CONST INT_T | fd | ) |
Get no block file descriptors
[in] | fd | file descriptor |
OPERATE_RET tal_net_get_socket_ip | ( | INT_T | fd, |
TUYA_IP_ADDR_T * | addr | ||
) |
Get ip address by socket fd
[in] | fd | file descriptor |
[out] | addr | ip address |
OPERATE_RET tal_net_gethostbyname | ( | IN CONST CHAR_T * | domain, |
IN CONST DNS_MODE_E | mode, | ||
OUT TUYA_IP_ADDR_T * | addr | ||
) |
Get address information by domain
[in] | domain | domain information |
[in] | addr | address information |
OPERATE_RET tal_net_getsockopt | ( | CONST INT_T | fd, |
CONST TUYA_OPT_LEVEL | level, | ||
CONST TUYA_OPT_NAME | optname, | ||
VOID_T * | optval, | ||
INT_T * | optlen | ||
) |
Get socket options
[in] | fd | file descriptor |
[in] | level | getting level |
[in] | optname | the name of the option |
[out] | optval | the value of option |
[out] | optlen | the length of the option value |
TUYA_ERRNO tal_net_listen | ( | CONST INT_T | fd, |
CONST INT_T | backlog | ||
) |
Listen to network
[in] | fd | file descriptor |
[in] | backlog | max count of backlog connection |
TUYA_ERRNO tal_net_recv | ( | CONST INT_T | fd, |
VOID_T * | buf, | ||
CONST UINT_T | nbytes | ||
) |
Receive data from network
[in] | fd | file descriptor |
[in] | buf | receive data buffer |
[in] | nbytes | buffer lenth |
INT_T tal_net_recv_nd_size | ( | CONST INT_T | fd, |
VOID_T * | buf, | ||
CONST UINT_T | buf_size, | ||
CONST UINT_T | nd_size | ||
) |
Receive data from network with need size
[in] | fd | file descriptor |
[in] | buf | receive data buffer |
[in] | nbytes | buffer lenth |
[in] | nd_size | the need size |
TUYA_ERRNO tal_net_recvfrom | ( | CONST INT_T | fd, |
VOID_T * | buf, | ||
CONST UINT_T | nbytes, | ||
TUYA_IP_ADDR_T * | addr, | ||
UINT16_T * | port | ||
) |
Receive data from specified server
[in] | fd | file descriptor |
[in] | buf | receive data buffer |
[in] | nbytes | buffer lenth |
[in] | addr | address information of server |
[in] | port | port information of server |
INT_T tal_net_select | ( | CONST INT_T | maxfd, |
TUYA_FD_SET_T * | readfds, | ||
TUYA_FD_SET_T * | writefds, | ||
TUYA_FD_SET_T * | errorfds, | ||
CONST UINT_T | ms_timeout | ||
) |
Get available file descriptors
[in] | maxfd | max count of file descriptor |
[out] | readfds | a set of readalbe file descriptor |
[out] | writefds | a set of writable file descriptor |
[out] | errorfds | a set of except file descriptor |
[in] | ms_timeout | time out |
TUYA_ERRNO tal_net_send | ( | CONST INT_T | fd, |
CONST VOID_T * | buf, | ||
CONST UINT_T | nbytes | ||
) |
Send data to network
[in] | fd | file descriptor |
[in] | buf | send data buffer |
[in] | nbytes | buffer lenth |
TUYA_ERRNO tal_net_send_to | ( | CONST INT_T | fd, |
CONST VOID_T * | buf, | ||
CONST UINT_T | nbytes, | ||
CONST TUYA_IP_ADDR_T | addr, | ||
CONST UINT16_T | port | ||
) |
Send data to specified server
[in] | fd | file descriptor |
[in] | buf | send data buffer |
[in] | nbytes | buffer lenth |
[in] | addr | address information of server |
[in] | port | port information of server |
OPERATE_RET tal_net_set_block | ( | CONST INT_T | fd, |
CONST BOOL_T | block | ||
) |
Set block flag for file descriptors
[in] | fd | file descriptor |
[in] | block | block flag |
OPERATE_RET tal_net_set_broadcast | ( | CONST INT_T | fd | ) |
Enable broadcast option of socket fd
[in] | fd | file descriptor |
OPERATE_RET tal_net_set_bufsize | ( | CONST INT_T | fd, |
CONST INT_T | buf_size, | ||
CONST TUYA_TRANS_TYPE_E | type | ||
) |
Set buffer_size option of socket fd
[in] | fd | file descriptor |
[in] | buf_size | buffer size in byte |
[in] | type | transfer type, receive or send |
OPERATE_RET tal_net_set_keepalive | ( | INT_T | fd, |
CONST BOOL_T | alive, | ||
CONST UINT_T | idle, | ||
CONST UINT_T | intr, | ||
CONST UINT_T | cnt | ||
) |
Set keepalive option of socket fd to monitor the connection
[in] | fd | file descriptor |
[in] | alive | keepalive option, enable or disable option |
[in] | idle | keep idle option, if the connection has no data exchange with the idle time(in seconds), start probe. |
[in] | intr | keep interval option, the probe time interval. |
[in] | cnt | keep count option, probe count. |
OPERATE_RET tal_net_set_reuse | ( | CONST INT_T | fd | ) |
Enable reuse option of socket fd
[in] | fd | file descriptor |
OPERATE_RET tal_net_set_timeout | ( | CONST INT_T | fd, |
CONST INT_T | ms_timeout, | ||
CONST TUYA_TRANS_TYPE_E | type | ||
) |
Set timeout option of socket fd
[in] | fd | file descriptor |
[in] | ms_timeout | timeout in ms |
[in] | type | transfer type, receive or send |
OPERATE_RET tal_net_sethostname | ( | CONST CHAR_T * | hostname | ) |
Set the system hostname
[in] | hostname | hostname to set |
OPERATE_RET tal_net_setsockopt | ( | CONST INT_T | fd, |
CONST TUYA_OPT_LEVEL | level, | ||
CONST TUYA_OPT_NAME | optname, | ||
CONST VOID_T * | optval, | ||
CONST INT_T | optlen | ||
) |
Set socket options
[in] | fd | file descriptor |
[in] | level | setting level |
[in] | optname | the name of the option |
[in] | optval | the value of option |
[in] | optlen | the length of the option value |
INT_T tal_net_socket_create | ( | CONST TUYA_PROTOCOL_TYPE_E | type | ) |
Create a tcp/udp socket
[in] | type | protocol type, tcp or udp |
INT_T tal_net_socket_create_v6 | ( | IN CONST TUYA_PROTOCOL_TYPE_E | type | ) |
Create a IPv6 tcp/udp socket
[in] | type | protocol type, tcp or udp |
TUYA_IP_ADDR_T tal_net_str2addr | ( | CONST CHAR_T * | ip_str | ) |
Change ip string to address
[in] | ip_str | ip string |