TuyaOS
宏定义 | 类型定义 | 函数
tuya_hal_network.h 文件参考

Common process - Initialization 更多...

#include "tal_network.h"
#include <errno.h>
tuya_hal_network.h 的引用(Include)关系图:
此图展示该文件直接或间接的被哪些文件引用了:

浏览源代码.

宏定义

#define tuya_hal_net_accept(fd, addr, port)   tal_net_accept(fd, addr, port)
 Accept the coming socket connection of the server fd 更多...
 
#define tuya_hal_net_addr(ip)   tal_net_str2addr(ip)
 Get ip address by ip string 更多...
 
#define tuya_hal_net_addr2str(ipaddr)   tal_net_addr2str(ipaddr)
 Change ip address to string 更多...
 
#define tuya_hal_net_bind(fd, addr, port)   tal_net_bind(fd, addr, port)
 Bind to network 更多...
 
#define tuya_hal_net_close(fd)   tal_net_close(fd)
 Close file descriptors 更多...
 
#define tuya_hal_net_connect(fd, addr, port)   tal_net_connect(fd, addr, port)
 Connect to network 更多...
 
#define tuya_hal_net_connect_raw(fd, p_socket, len)   tal_net_connect_raw(fd, p_socket, len)
 Connect to network with raw data 更多...
 
#define tuya_hal_net_disable_nagle(fd)   tal_net_disable_nagle(fd)
 Disable nagle option of socket fd 更多...
 
#define tuya_hal_net_fd_clear(fd, fds)   tal_net_fd_clear(fd, fds)
 Clear file descriptor from set 更多...
 
#define tuya_hal_net_fd_isset(fd, fds)   tal_net_fd_isset(fd, fds)
 Check file descriptor is in set 更多...
 
#define tuya_hal_net_fd_set(fd, fds)   tal_net_fd_set(fd, fds)
 Add file descriptor to set 更多...
 
#define tuya_hal_net_fd_zero(fds)   tal_net_fd_zero(fds)
 Clear all file descriptor in set 更多...
 
#define tuya_hal_net_get_errno()   tal_net_get_errno()
 Get error code of network 更多...
 
#define tuya_hal_net_get_nonblock(fd)   tal_net_get_nonblock(fd)
 Get no block file descriptors 更多...
 
#define tuya_hal_net_get_socket_ip(fd, addr)   tal_net_get_socket_ip(fd, addr)
 Get ip address by socket fd 更多...
 
#define tuya_hal_net_gethostbyname(domain, addr)   tal_net_gethostbyname(domain, addr)
 Get address information by domain 更多...
 
#define tuya_hal_net_listen(fd, backlog)   tal_net_listen(fd, backlog)
 Listen to network 更多...
 
#define tuya_hal_net_recv(fd, buf, nbytes)   tal_net_recv(fd, buf, nbytes)
 Receive data from network 更多...
 
#define tuya_hal_net_recv_nd_size(fd, buf, buf_size, nd_size)    tal_net_recv_nd_size(fd, buf, buf_size, nd_size)
 Receive data from network with need size 更多...
 
#define tuya_hal_net_recvfrom(fd, buf, nbytes, addr, port)    tal_net_recvfrom(fd, buf, nbytes, addr, port)
 Receive data from specified server 更多...
 
#define tuya_hal_net_select(maxfd, readfds, writefds, errorfds, ms_timeout)    tal_net_select(maxfd, readfds, writefds, errorfds, ms_timeout)
 Get available file descriptors 更多...
 
#define tuya_hal_net_send(fd, buf, nbytes)   tal_net_send(fd, buf, nbytes)
 Send data to network 更多...
 
#define tuya_hal_net_send_to(fd, buf, nbytes, addr, port)    tal_net_send_to(fd, buf, nbytes, addr, port)
 Send data to specified server 更多...
 
#define tuya_hal_net_set_block(fd, block)   tal_net_set_block(fd, block)
 Set block flag for file descriptors 更多...
 
#define tuya_hal_net_set_boardcast(fd)   tal_net_set_broadcast(fd)
 Enable broadcast option of socket fd 更多...
 
#define tuya_hal_net_set_bufsize(fd, buf_size, type)   tal_net_set_bufsize(fd, buf_size, type)
 Set buffer_size option of socket fd 更多...
 
#define tuya_hal_net_set_keepalive(fd, alive, idle, intr, cnt)   tal_net_set_keepalive(fd, alive, idle, intr, cnt)
 Set keepalive option of socket fd to monitor the connection 更多...
 
#define tuya_hal_net_set_reuse(fd)   tal_net_set_reuse(fd)
 Enable reuse option of socket fd 更多...
 
#define tuya_hal_net_set_timeout(fd, ms_timeout, type)   tal_net_set_timeout(fd, ms_timeout, type)
 Set timeout option of socket fd 更多...
 
#define tuya_hal_net_socket_create(type)   tal_net_socket_create(type)
 Create a tcp/udp socket 更多...
 
#define tuya_hal_net_str2addr(ip_str)   tal_net_str2addr(ip_str)
 Change ip string to address 更多...
 
#define UNW_FD_CLR(n, p)   TAL_FD_CLR(n, p)
 
#define UNW_FD_ISSET(n, p)   TAL_FD_ISSET(n,p)
 
#define UNW_FD_SET(n, p)   TAL_FD_SET(n, p)
 
#define UNW_FD_ZERO(p)   TAL_FD_ZERO(p)
 
#define UNW_SHUT_RD   0
 
#define UNW_SHUT_RDWR   2
 
#define UNW_SHUT_WR   1
 

类型定义

typedef TUYA_FD_SET_T UNW_FD_SET_T
 
typedef TUYA_IP_ADDR_T UNW_IP_ADDR_T
 
typedef TUYA_PROTOCOL_TYPE_E UNW_PROTOCOL_TYPE
 
typedef TUYA_TRANS_TYPE_E UNW_TRANS_TYPE_E
 

函数

int tuya_hal_net_socket_bind (int fd, const char *ip)
 Bind to network with specified ip 更多...
 

详细描述

Common process - Initialization

版本
0.1
日期
2020-11-09

宏定义说明

◆ tuya_hal_net_accept

#define tuya_hal_net_accept (   fd,
  addr,
  port 
)    tal_net_accept(fd, addr, port)

Accept the coming socket connection of the server fd

参数
[in]fdfile descriptor
[in]addraddress information of server
[in]portport information of server
注解
This API is used for accepting the coming socket connection of the server fd.
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_addr

#define tuya_hal_net_addr (   ip)    tal_net_str2addr(ip)

Get ip address by ip string

参数
[in]ipip string
注解
This API is used for getting ip address by ip string
返回
ip address

◆ tuya_hal_net_addr2str

#define tuya_hal_net_addr2str (   ipaddr)    tal_net_addr2str(ipaddr)

Change ip address to string

参数
[in]ipaddrip address
注解
This API is used to change ip address(in host byte order) to string(in IPv4 numbers-and-dots(xx.xx.xx.xx) notion).
返回
ip string

◆ tuya_hal_net_bind

#define tuya_hal_net_bind (   fd,
  addr,
  port 
)    tal_net_bind(fd, addr, port)

Bind to network

参数
[in]fdfile descriptor
[in]addraddress information of server
[in]portport information of server
注解
This API is used for binding to network.
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_close

#define tuya_hal_net_close (   fd)    tal_net_close(fd)

Close file descriptors

参数
[in]fdfile descriptor
注解
This API is used to close file descriptors.
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_connect

#define tuya_hal_net_connect (   fd,
  addr,
  port 
)    tal_net_connect(fd, addr, port)

Connect to network

参数
[in]fdfile descriptor
[in]addraddress information of server
[in]portport information of server
注解
This API is used for connecting to network.
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_connect_raw

#define tuya_hal_net_connect_raw (   fd,
  p_socket,
  len 
)    tal_net_connect_raw(fd, p_socket, len)

Connect to network with raw data

参数
[in]fdfile descriptor
[in]p_socketraw socket data
[in]lendata lenth
注解
This API is used for connecting to network with raw data.
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_disable_nagle

#define tuya_hal_net_disable_nagle (   fd)    tal_net_disable_nagle(fd)

Disable nagle option of socket fd

参数
[in]fdfile descriptor
注解
This API is used to disable nagle option of socket fd.
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_fd_clear

#define tuya_hal_net_fd_clear (   fd,
  fds 
)    tal_net_fd_clear(fd, fds)

Clear file descriptor from set

参数
[in]fdfile descriptor
[in]fdsset of file descriptor
注解
This API is used to clear file descriptor from set.
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tuya_hal_net_fd_isset

#define tuya_hal_net_fd_isset (   fd,
  fds 
)    tal_net_fd_isset(fd, fds)

Check file descriptor is in set

参数
[in]fdfile descriptor
[in]fdsset of file descriptor
注解
This API is used to check the file descriptor is in set.
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tuya_hal_net_fd_set

#define tuya_hal_net_fd_set (   fd,
  fds 
)    tal_net_fd_set(fd, fds)

Add file descriptor to set

参数
[in]fdfile descriptor
[in]fdsset of file descriptor
注解
This API is used to add file descriptor to set.
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tuya_hal_net_fd_zero

#define tuya_hal_net_fd_zero (   fds)    tal_net_fd_zero(fds)

Clear all file descriptor in set

参数
[in]fdsset of file descriptor
注解
This API is used to clear all file descriptor in set.
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tuya_hal_net_get_errno

#define tuya_hal_net_get_errno ( )    tal_net_get_errno()

Get error code of network

参数
void
注解
This API is used for getting error code of network.
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_get_nonblock

#define tuya_hal_net_get_nonblock (   fd)    tal_net_get_nonblock(fd)

Get no block file descriptors

参数
[in]fdfile descriptor
注解
This API is used to get no block file descriptors.
返回
the count of no block file descriptors.

◆ tuya_hal_net_get_socket_ip

#define tuya_hal_net_get_socket_ip (   fd,
  addr 
)    tal_net_get_socket_ip(fd, addr)

Get ip address by socket fd

参数
[in]fdfile descriptor
[out]addrip address
注解
This API is used for getting ip address by socket fd.
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_gethostbyname

#define tuya_hal_net_gethostbyname (   domain,
  addr 
)    tal_net_gethostbyname(domain, addr)

Get address information by domain

参数
[in]domaindomain information
[in]addraddress information
注解
This API is used for getting address information by domain.
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_listen

#define tuya_hal_net_listen (   fd,
  backlog 
)    tal_net_listen(fd, backlog)

Listen to network

参数
[in]fdfile descriptor
[in]backlogmax count of backlog connection
注解
This API is used for listening to network.
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_recv

#define tuya_hal_net_recv (   fd,
  buf,
  nbytes 
)    tal_net_recv(fd, buf, nbytes)

Receive data from network

参数
[in]fdfile descriptor
[in]bufreceive data buffer
[in]nbytesbuffer lenth
注解
This API is used for receiving data from network
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_recv_nd_size

#define tuya_hal_net_recv_nd_size (   fd,
  buf,
  buf_size,
  nd_size 
)     tal_net_recv_nd_size(fd, buf, buf_size, nd_size)

Receive data from network with need size

参数
[in]fdfile descriptor
[in]bufreceive data buffer
[in]nbytesbuffer lenth
[in]nd_sizethe need size
注解
This API is used for receiving data from network with need size
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_recvfrom

#define tuya_hal_net_recvfrom (   fd,
  buf,
  nbytes,
  addr,
  port 
)     tal_net_recvfrom(fd, buf, nbytes, addr, port)

Receive data from specified server

参数
[in]fdfile descriptor
[in]bufreceive data buffer
[in]nbytesbuffer lenth
[in]addraddress information of server
[in]portport information of server
注解
This API is used for receiving data from specified server
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_select

#define tuya_hal_net_select (   maxfd,
  readfds,
  writefds,
  errorfds,
  ms_timeout 
)     tal_net_select(maxfd, readfds, writefds, errorfds, ms_timeout)

Get available file descriptors

参数
[in]maxfdmax count of file descriptor
[out]readfdsa set of readalbe file descriptor
[out]writefdsa set of writable file descriptor
[out]errorfdsa set of except file descriptor
[in]ms_timeouttime out
注解
This API is used to get available file descriptors.
返回
the count of available file descriptors.

◆ tuya_hal_net_send

#define tuya_hal_net_send (   fd,
  buf,
  nbytes 
)    tal_net_send(fd, buf, nbytes)

Send data to network

参数
[in]fdfile descriptor
[in]bufsend data buffer
[in]nbytesbuffer lenth
注解
This API is used for sending data to network
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_send_to

#define tuya_hal_net_send_to (   fd,
  buf,
  nbytes,
  addr,
  port 
)     tal_net_send_to(fd, buf, nbytes, addr, port)

Send data to specified server

参数
[in]fdfile descriptor
[in]bufsend data buffer
[in]nbytesbuffer lenth
[in]addraddress information of server
[in]portport information of server
注解
This API is used for sending data to network
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_set_block

#define tuya_hal_net_set_block (   fd,
  block 
)    tal_net_set_block(fd, block)

Set block flag for file descriptors

参数
[in]fdfile descriptor
[in]blockblock flag
注解
This API is used to set block flag for file descriptors.
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_set_boardcast

#define tuya_hal_net_set_boardcast (   fd)    tal_net_set_broadcast(fd)

Enable broadcast option of socket fd

参数
[in]fdfile descriptor
注解
This API is used to enable broadcast option of socket fd.
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_set_bufsize

#define tuya_hal_net_set_bufsize (   fd,
  buf_size,
  type 
)    tal_net_set_bufsize(fd, buf_size, type)

Set buffer_size option of socket fd

参数
[in]fdfile descriptor
[in]buf_sizebuffer size in byte
[in]typetransfer type, receive or send
注解
This API is used for setting buffer_size option of socket fd.
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_set_keepalive

#define tuya_hal_net_set_keepalive (   fd,
  alive,
  idle,
  intr,
  cnt 
)    tal_net_set_keepalive(fd, alive, idle, intr, cnt)

Set keepalive option of socket fd to monitor the connection

参数
[in]fdfile descriptor
[in]alivekeepalive option, enable or disable option
[in]idlekeep idle option, if the connection has no data exchange with the idle time(in seconds), start probe.
[in]intrkeep interval option, the probe time interval.
[in]cntkeep count option, probe count.
注解
This API is used to set keepalive option of socket fd to monitor the connection.
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_set_reuse

#define tuya_hal_net_set_reuse (   fd)    tal_net_set_reuse(fd)

Enable reuse option of socket fd

参数
[in]fdfile descriptor
注解
This API is used to enable reuse option of socket fd.
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_set_timeout

#define tuya_hal_net_set_timeout (   fd,
  ms_timeout,
  type 
)    tal_net_set_timeout(fd, ms_timeout, type)

Set timeout option of socket fd

参数
[in]fdfile descriptor
[in]ms_timeouttimeout in ms
[in]typetransfer type, receive or send
注解
This API is used for setting timeout option of socket fd.
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h

◆ tuya_hal_net_socket_create

#define tuya_hal_net_socket_create (   type)    tal_net_socket_create(type)

Create a tcp/udp socket

参数
[in]typeprotocol type, tcp or udp
注解
This API is used for creating a tcp/udp socket.
返回
file descriptor

◆ tuya_hal_net_str2addr

#define tuya_hal_net_str2addr (   ip_str)    tal_net_str2addr(ip_str)

Change ip string to address

参数
[in]ip_strip string
注解
This API is used to change ip string to address.
返回
ip address

函数说明

◆ tuya_hal_net_socket_bind()

int tuya_hal_net_socket_bind ( int  fd,
const char *  ip 
)

Bind to network with specified ip

参数
[in]fdfile descriptor
[in]ipip address
注解
This API is used for binding to network with specified ip.
返回
UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h