43 #ifndef _AWS_SECURE_SOCKETS_H_ 44 #define _AWS_SECURE_SOCKETS_H_ 53 #include "aws_secure_sockets_config.h" 54 #include "aws_secure_sockets_config_defaults.h" 55 #include "aws_lib_init.h" 70 #define Socklen_t uint32_t 83 #define SOCKETS_ERROR_NONE ( 0 ) 84 #define SOCKETS_SOCKET_ERROR ( -1 ) 85 #define SOCKETS_EWOULDBLOCK ( -11 ) 86 #define SOCKETS_ENOMEM ( -12 ) 87 #define SOCKETS_EINVAL ( -22 ) 88 #define SOCKETS_ENOPROTOOPT ( -109 ) 89 #define SOCKETS_ENOTCONN ( -126 ) 90 #define SOCKETS_EISCONN ( -127 ) 91 #define SOCKETS_ECLOSED ( -128 ) 92 #define SOCKETS_TLS_INIT_ERROR ( -1001 ) 93 #define SOCKETS_TLS_HANDSHAKE_ERROR ( -1002 ) 94 #define SOCKETS_TLS_SERVER_UNVERIFIED ( -1003 ) 95 #define SOCKETS_TLS_RECV_ERROR ( -1004 ) 96 #define SOCKETS_TLS_SEND_ERROR ( -1005 ) 97 #define SOCKETS_PERIPHERAL_RESET ( -1006 ) 103 #define SOCKETS_INVALID_SOCKET ( ( Socket_t ) ~0U ) 114 #define SOCKETS_AF_INET ( 2 ) 115 #define SOCKETS_PF_INET SOCKETS_AF_INET 116 #define SOCKETS_AF_INET6 ( 10 ) 128 #define SOCKETS_SOCK_DGRAM ( 2 ) 129 #define SOCKETS_SOCK_STREAM ( 1 ) 139 #define SOCKETS_IPPROTO_UDP ( 17 ) 140 #define SOCKETS_IPPROTO_TCP ( 6 ) 150 #define SOCKETS_SO_RCVTIMEO ( 0 ) 151 #define SOCKETS_SO_SNDTIMEO ( 1 ) 152 #define SOCKETS_SO_SNDBUF ( 4 ) 153 #define SOCKETS_SO_RCVBUF ( 5 ) 154 #define SOCKETS_SO_SERVER_NAME_INDICATION ( 6 ) 155 #define SOCKETS_SO_TRUSTED_SERVER_CERTIFICATE ( 7 ) 156 #define SOCKETS_SO_REQUIRE_TLS ( 8 ) 157 #define SOCKETS_SO_NONBLOCK ( 9 ) 158 #define SOCKETS_SO_ALPN_PROTOCOLS ( 10 ) 159 #define SOCKETS_SO_WAKEUP_CALLBACK ( 17 ) 169 #define SOCKETS_SHUT_RD ( 0 ) 170 #define SOCKETS_SHUT_WR ( 1 ) 171 #define SOCKETS_SHUT_RDWR ( 2 ) 177 #define securesocketsMAX_DNS_NAME_LENGTH ( 253 ) 195 #define securesocketsDEFAULT_TLS_DESTINATION_PORT 443 280 size_t xBufferLength,
299 const void * pvBuffer,
339 #define socketsAWS_IOT_ALPN_MQTT "x-amzn-mqtt-ca" 413 const void * pvOptionValue,
414 size_t xOptionLength );
434 #if defined( socketsconfigBYTE_ORDER ) && ( socketsconfigBYTE_ORDER == pdLITTLE_ENDIAN ) 435 #define SOCKETS_htonl( ulIn ) ( ( uint32_t ) ( ( ( ulIn & 0xFF ) << 24 ) | ( ( ulIn & 0xFF00 ) << 8 ) | ( ( ulIn & 0xFF0000 ) >> 8 ) | ( ( ulIn & 0xFF000000 ) >> 24 ) ) ) 437 #define SOCKETS_htonl( usIn ) ( ( uint32_t ) ( usIn ) ) 446 #define SOCKETS_ntohl( usIn ) SOCKETS_htonl( usIn ) 456 #if defined( socketsconfigBYTE_ORDER ) && ( socketsconfigBYTE_ORDER == pdLITTLE_ENDIAN ) 457 #define SOCKETS_htons( usIn ) ( ( uint16_t ) ( ( ( usIn ) << 8U ) | ( ( usIn ) >> 8U ) ) ) 459 #define SOCKETS_htons( usIn ) ( ( uint16_t ) ( usIn ) ) 469 #define SOCKETS_ntohs( usIn ) SOCKETS_htons( usIn ) 471 #if defined( socketsconfigBYTE_ORDER ) && ( socketsconfigBYTE_ORDER == pdLITTLE_ENDIAN ) 473 #define SOCKETS_inet_addr_quick( ucOctet0, ucOctet1, ucOctet2, ucOctet3 ) \ 474 ( ( ( ( uint32_t ) ( ucOctet3 ) ) << 24UL ) | \ 475 ( ( ( uint32_t ) ( ucOctet2 ) ) << 16UL ) | \ 476 ( ( ( uint32_t ) ( ucOctet1 ) ) << 8UL ) | \ 477 ( ( uint32_t ) ( ucOctet0 ) ) ) 479 #define SOCKETS_inet_ntoa( ulIPAddress, pucBuffer ) \ 480 sprintf( ( char * ) ( pucBuffer ), "%u.%u.%u.%u", \ 481 ( ( unsigned ) ( ( ulIPAddress ) & 0xffUL ) ), \ 482 ( ( unsigned ) ( ( ( ulIPAddress ) >> 8 ) & 0xffUL ) ), \ 483 ( ( unsigned ) ( ( ( ulIPAddress ) >> 16 ) & 0xffUL ) ), \ 484 ( ( unsigned ) ( ( ulIPAddress ) >> 24 ) ) ) 488 #define SOCKETS_inet_addr_quick( ucOctet0, ucOctet1, ucOctet2, ucOctet3 ) \ 489 ( ( ( ( uint32_t ) ( ucOctet0 ) ) << 24UL ) | \ 490 ( ( ( uint32_t ) ( ucOctet1 ) ) << 16UL ) | \ 491 ( ( ( uint32_t ) ( ucOctet2 ) ) << 8UL ) | \ 492 ( ( uint32_t ) ( ucOctet3 ) ) ) 494 #define SOCKETS_inet_ntoa( ulIPAddress, pucBuffer ) \ 495 sprintf( ( char * ) ( pucBuffer ), "%u.%u.%u.%u", \ 496 ( ( unsigned ) ( ( ulIPAddress ) >> 24 ) ), \ 497 ( ( unsigned ) ( ( ( ulIPAddress ) >> 16 ) & 0xffUL ) ), \ 498 ( ( unsigned ) ( ( ( ulIPAddress ) >> 8 ) & 0xffUL ) ), \ 499 ( ( unsigned ) ( ( ulIPAddress ) & 0xffUL ) ) ) int32_t SOCKETS_SetSockOpt(Socket_t xSocket, int32_t lLevel, int32_t lOptionName, const void *pvOptionValue, size_t xOptionLength)
Manipulates the options for the socket.
Socket_t SOCKETS_Socket(int32_t lDomain, int32_t lType, int32_t lProtocol)
Creates a TCP socket.
int32_t SOCKETS_Shutdown(Socket_t xSocket, uint32_t ulHow)
Closes all or part of a full-duplex connection on the socket.
int32_t SOCKETS_Send(Socket_t xSocket, const void *pvBuffer, size_t xDataLength, uint32_t ulFlags)
Transmit data to the remote socket.
lib_initDECLARE_LIB_INIT(SOCKETS_Init)
Secure Sockets library initialization function.
#define Socklen_t
The "size_t" of secure sockets.
struct SocketsSockaddr SocketsSockaddr_t
Socket address.
uint32_t SOCKETS_GetHostByName(const char *pcHostName)
Resolve a host name using Domain Name Service.
int32_t SOCKETS_Close(Socket_t xSocket)
Closes the socket and frees the related resources.
int32_t SOCKETS_Connect(Socket_t xSocket, SocketsSockaddr_t *pxAddress, Socklen_t xAddressLength)
Connects the socket to the specified IP address and port.
int32_t SOCKETS_Recv(Socket_t xSocket, void *pvBuffer, size_t xBufferLength, uint32_t ulFlags)
Receive data from a TCP socket.
void * Socket_t
The socket type.