FreeRTOS_Sockets.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. /*
  2. * FreeRTOS+TCP V2.3.2 LTS Patch 1
  3. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  6. * this software and associated documentation files (the "Software"), to deal in
  7. * the Software without restriction, including without limitation the rights to
  8. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  9. * the Software, and to permit persons to whom the Software is furnished to do so,
  10. * subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in all
  13. * copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  17. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  18. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  19. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  20. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * http://aws.amazon.com/freertos
  23. * http://www.FreeRTOS.org
  24. */
  25. #ifndef FREERTOS_SOCKETS_H
  26. #define FREERTOS_SOCKETS_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* Standard includes. */
  31. #include <string.h>
  32. /* Application level configuration options. */
  33. #include "FreeRTOSIPConfig.h"
  34. #ifndef FREERTOS_IP_CONFIG_H
  35. #error FreeRTOSIPConfig.h has not been included yet
  36. #endif
  37. /* Event bit definitions are required by the select functions. */
  38. #include "event_groups.h"
  39. #ifndef INC_FREERTOS_H
  40. #error FreeRTOS.h must be included before FreeRTOS_Sockets.h.
  41. #endif
  42. #ifndef INC_TASK_H
  43. #ifndef TASK_H /* For compatibility with older FreeRTOS versions. */
  44. #error The FreeRTOS header file task.h must be included before FreeRTOS_Sockets.h.
  45. #endif
  46. #endif
  47. /* Assigned to an Socket_t variable when the socket is not valid, probably
  48. * because it could not be created. */
  49. #define FREERTOS_INVALID_SOCKET ( ( Socket_t ) ~0U )
  50. /* API function error values. As errno is supported, the FreeRTOS sockets
  51. * functions return error codes rather than just a pass or fail indication. */
  52. /* HT: Extended the number of error codes, gave them positive values and if possible
  53. * the corresponding found in errno.h
  54. * In case of an error, API's will still return negative numbers, e.g.
  55. * return -pdFREERTOS_ERRNO_EWOULDBLOCK;
  56. * in case an operation would block */
  57. /* The following defines are obsolete, please use -pdFREERTOS_ERRNO_Exxx */
  58. #define FREERTOS_SOCKET_ERROR ( -1 )
  59. #define FREERTOS_EWOULDBLOCK ( -pdFREERTOS_ERRNO_EWOULDBLOCK )
  60. #define FREERTOS_EINVAL ( -pdFREERTOS_ERRNO_EINVAL )
  61. #define FREERTOS_EADDRNOTAVAIL ( -pdFREERTOS_ERRNO_EADDRNOTAVAIL )
  62. #define FREERTOS_EADDRINUSE ( -pdFREERTOS_ERRNO_EADDRINUSE )
  63. #define FREERTOS_ENOBUFS ( -pdFREERTOS_ERRNO_ENOBUFS )
  64. #define FREERTOS_ENOPROTOOPT ( -pdFREERTOS_ERRNO_ENOPROTOOPT )
  65. #define FREERTOS_ECLOSED ( -pdFREERTOS_ERRNO_ENOTCONN )
  66. /* Values for the parameters to FreeRTOS_socket(), inline with the Berkeley
  67. * standard. See the documentation of FreeRTOS_socket() for more information. */
  68. #define FREERTOS_AF_INET ( 2 )
  69. #define FREERTOS_AF_INET6 ( 10 )
  70. #define FREERTOS_SOCK_DGRAM ( 2 )
  71. #define FREERTOS_IPPROTO_UDP ( 17 )
  72. #define FREERTOS_SOCK_STREAM ( 1 )
  73. #define FREERTOS_IPPROTO_TCP ( 6 )
  74. /* IP packet of type "Any local network"
  75. * can be used in stead of TCP for testing with sockets in raw mode
  76. */
  77. #define FREERTOS_IPPROTO_USR_LAN ( 63 )
  78. /* A bit value that can be passed into the FreeRTOS_sendto() function as part of
  79. * the flags parameter. Setting the FREERTOS_ZERO_COPY in the flags parameter
  80. * indicates that the zero copy interface is being used. See the documentation for
  81. * FreeRTOS_sockets() for more information. */
  82. #define FREERTOS_ZERO_COPY ( 1 )
  83. /* Values that can be passed in the option name parameter of calls to
  84. * FreeRTOS_setsockopt(). */
  85. #define FREERTOS_SO_RCVTIMEO ( 0 ) /* Used to set the receive time out. */
  86. #define FREERTOS_SO_SNDTIMEO ( 1 ) /* Used to set the send time out. */
  87. #define FREERTOS_SO_UDPCKSUM_OUT ( 2 ) /* Used to turn the use of the UDP checksum by a socket on or off. This also doubles as part of an 8-bit bitwise socket option. */
  88. #if ( ipconfigSOCKET_HAS_USER_SEMAPHORE == 1 )
  89. #define FREERTOS_SO_SET_SEMAPHORE ( 3 ) /* Used to set a user's semaphore */
  90. #endif
  91. #define FREERTOS_SO_SNDBUF ( 4 ) /* Set the size of the send buffer (TCP only) */
  92. #define FREERTOS_SO_RCVBUF ( 5 ) /* Set the size of the receive buffer (TCP only) */
  93. #if ipconfigUSE_CALLBACKS == 1
  94. #define FREERTOS_SO_TCP_CONN_HANDLER ( 6 ) /* Install a callback for (dis) connection events. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */
  95. #define FREERTOS_SO_TCP_RECV_HANDLER ( 7 ) /* Install a callback for receiving TCP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */
  96. #define FREERTOS_SO_TCP_SENT_HANDLER ( 8 ) /* Install a callback for sending TCP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */
  97. #define FREERTOS_SO_UDP_RECV_HANDLER ( 9 ) /* Install a callback for receiving UDP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */
  98. #define FREERTOS_SO_UDP_SENT_HANDLER ( 10 ) /* Install a callback for sending UDP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */
  99. #endif /* ipconfigUSE_CALLBACKS */
  100. #define FREERTOS_SO_REUSE_LISTEN_SOCKET ( 11 ) /* When a listening socket gets connected, do not create a new one but re-use it */
  101. #define FREERTOS_SO_CLOSE_AFTER_SEND ( 12 ) /* As soon as the last byte has been transmitted, finalise the connection */
  102. #define FREERTOS_SO_WIN_PROPERTIES ( 13 ) /* Set all buffer and window properties in one call, parameter is pointer to WinProperties_t */
  103. #define FREERTOS_SO_SET_FULL_SIZE ( 14 ) /* Refuse to send packets smaller than MSS */
  104. #define FREERTOS_SO_STOP_RX ( 15 ) /* Temporarily hold up reception, used by streaming client */
  105. #if ( ipconfigUDP_MAX_RX_PACKETS > 0 )
  106. #define FREERTOS_SO_UDP_MAX_RX_PACKETS ( 16 ) /* This option helps to limit the maximum number of packets a UDP socket will buffer */
  107. #endif
  108. #if ( ipconfigSOCKET_HAS_USER_WAKE_CALLBACK == 1 )
  109. #define FREERTOS_SO_WAKEUP_CALLBACK ( 17 )
  110. #endif
  111. #define FREERTOS_SO_SET_LOW_HIGH_WATER ( 18 )
  112. #define FREERTOS_NOT_LAST_IN_FRAGMENTED_PACKET ( 0x80 ) /* For internal use only, but also part of an 8-bit bitwise value. */
  113. #define FREERTOS_FRAGMENTED_PACKET ( 0x40 ) /* For internal use only, but also part of an 8-bit bitwise value. */
  114. /* Values for flag for FreeRTOS_shutdown(). */
  115. #define FREERTOS_SHUT_RD ( 0 ) /* Not really at this moment, just for compatibility of the interface */
  116. #define FREERTOS_SHUT_WR ( 1 )
  117. #define FREERTOS_SHUT_RDWR ( 2 )
  118. /* Values for flag for FreeRTOS_recv(). */
  119. #define FREERTOS_MSG_OOB ( 2 ) /* process out-of-band data */
  120. #define FREERTOS_MSG_PEEK ( 4 ) /* peek at incoming message */
  121. #define FREERTOS_MSG_DONTROUTE ( 8 ) /* send without using routing tables */
  122. #define FREERTOS_MSG_DONTWAIT ( 16 ) /* Can be used with recvfrom(), sendto(), recv(), and send(). */
  123. /**
  124. * Structure to hold the properties of Tx/Rx buffers and windows.
  125. */
  126. typedef struct xWIN_PROPS
  127. {
  128. /* Properties of the Tx buffer and Tx window */
  129. int32_t lTxBufSize; /**< Unit: bytes */
  130. int32_t lTxWinSize; /**< Unit: MSS */
  131. /* Properties of the Rx buffer and Rx window */
  132. int32_t lRxBufSize; /**< Unit: bytes */
  133. int32_t lRxWinSize; /**< Unit: MSS */
  134. } WinProperties_t;
  135. /**
  136. * Structure to pass for the 'FREERTOS_SO_SET_LOW_HIGH_WATER' option
  137. */
  138. typedef struct xLOW_HIGH_WATER
  139. {
  140. size_t uxLittleSpace; /**< Send a STOP when buffer space drops below X bytes */
  141. size_t uxEnoughSpace; /**< Send a GO when buffer space grows above X bytes */
  142. } LowHighWater_t;
  143. /* For compatibility with the expected Berkeley sockets naming. */
  144. #define socklen_t uint32_t
  145. /**
  146. * For this limited implementation, only two members are required in the
  147. * Berkeley style sockaddr structure.
  148. */
  149. struct freertos_sockaddr
  150. {
  151. /* _HT_ On 32- and 64-bit architectures, the addition of the two uint8_t
  152. * fields doesn't make the structure bigger, due to alignment.
  153. * The fields are inserted as a preparation for IPv6. */
  154. /* sin_len and sin_family not used in the IPv4-only release. */
  155. uint8_t sin_len; /**< length of this structure. */
  156. uint8_t sin_family; /**< FREERTOS_AF_INET. */
  157. uint16_t sin_port; /**< The port */
  158. uint32_t sin_addr; /**< The IP address */
  159. };
  160. extern const char * FreeRTOS_inet_ntoa( uint32_t ulIPAddress,
  161. char * pcBuffer );
  162. #if ipconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN
  163. #define FreeRTOS_inet_addr_quick( ucOctet0, ucOctet1, ucOctet2, ucOctet3 ) \
  164. ( ( ( ( uint32_t ) ( ucOctet3 ) ) << 24UL ) | \
  165. ( ( ( uint32_t ) ( ucOctet2 ) ) << 16UL ) | \
  166. ( ( ( uint32_t ) ( ucOctet1 ) ) << 8UL ) | \
  167. ( ( uint32_t ) ( ucOctet0 ) ) )
  168. #else /* ipconfigBYTE_ORDER */
  169. #define FreeRTOS_inet_addr_quick( ucOctet0, ucOctet1, ucOctet2, ucOctet3 ) \
  170. ( ( ( ( uint32_t ) ( ucOctet0 ) ) << 24UL ) | \
  171. ( ( ( uint32_t ) ( ucOctet1 ) ) << 16UL ) | \
  172. ( ( ( uint32_t ) ( ucOctet2 ) ) << 8UL ) | \
  173. ( ( uint32_t ) ( ucOctet3 ) ) )
  174. #endif /* ipconfigBYTE_ORDER */
  175. /* The socket type itself. */
  176. struct xSOCKET;
  177. typedef struct xSOCKET * Socket_t;
  178. typedef struct xSOCKET const * ConstSocket_t;
  179. static portINLINE BaseType_t xSocketValid( Socket_t xSocket )
  180. {
  181. BaseType_t xReturnValue = pdFALSE;
  182. /*
  183. * There are two values which can indicate an invalid socket:
  184. * FREERTOS_INVALID_SOCKET and NULL. In order to compare against
  185. * both values, the code cannot be compliant with rule 11.4,
  186. * hence the Coverity suppression statement below.
  187. */
  188. /* coverity[misra_c_2012_rule_11_4_violation] */
  189. if( ( xSocket != FREERTOS_INVALID_SOCKET ) && ( xSocket != NULL ) )
  190. {
  191. xReturnValue = pdTRUE;
  192. }
  193. return xReturnValue;
  194. }
  195. #if ( ipconfigSUPPORT_SELECT_FUNCTION == 1 )
  196. /* The SocketSet_t type is the equivalent to the fd_set type used by the
  197. * Berkeley API. */
  198. struct xSOCKET_SET;
  199. typedef struct xSOCKET_SET * SocketSet_t;
  200. #endif /* ( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) */
  201. /**
  202. * FULL, UP-TO-DATE AND MAINTAINED REFERENCE DOCUMENTATION FOR ALL THESE
  203. * FUNCTIONS IS AVAILABLE ON THE FOLLOWING URL:
  204. * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/FreeRTOS_TCP_API_Functions.html
  205. */
  206. Socket_t FreeRTOS_socket( BaseType_t xDomain,
  207. BaseType_t xType,
  208. BaseType_t xProtocol );
  209. int32_t FreeRTOS_recvfrom( Socket_t xSocket,
  210. void * pvBuffer,
  211. size_t uxBufferLength,
  212. BaseType_t xFlags,
  213. struct freertos_sockaddr * pxSourceAddress,
  214. socklen_t * pxSourceAddressLength );
  215. int32_t FreeRTOS_sendto( Socket_t xSocket,
  216. const void * pvBuffer,
  217. size_t uxTotalDataLength,
  218. BaseType_t xFlags,
  219. const struct freertos_sockaddr * pxDestinationAddress,
  220. socklen_t xDestinationAddressLength );
  221. BaseType_t FreeRTOS_bind( Socket_t xSocket,
  222. struct freertos_sockaddr const * pxAddress,
  223. socklen_t xAddressLength );
  224. /* function to get the local address and IP port */
  225. size_t FreeRTOS_GetLocalAddress( ConstSocket_t xSocket,
  226. struct freertos_sockaddr * pxAddress );
  227. #if ( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 1 )
  228. /* Returns true if an UDP socket exists bound to mentioned port number. */
  229. BaseType_t xPortHasUDPSocket( uint16_t usPortNr );
  230. #endif
  231. #if ipconfigUSE_TCP == 1
  232. BaseType_t FreeRTOS_connect( Socket_t xClientSocket,
  233. struct freertos_sockaddr * pxAddress,
  234. socklen_t xAddressLength );
  235. BaseType_t FreeRTOS_listen( Socket_t xSocket,
  236. BaseType_t xBacklog );
  237. BaseType_t FreeRTOS_recv( Socket_t xSocket,
  238. void * pvBuffer,
  239. size_t uxBufferLength,
  240. BaseType_t xFlags );
  241. BaseType_t FreeRTOS_send( Socket_t xSocket,
  242. const void * pvBuffer,
  243. size_t uxDataLength,
  244. BaseType_t xFlags );
  245. Socket_t FreeRTOS_accept( Socket_t xServerSocket,
  246. struct freertos_sockaddr * pxAddress,
  247. socklen_t * pxAddressLength );
  248. BaseType_t FreeRTOS_shutdown( Socket_t xSocket,
  249. BaseType_t xHow );
  250. #if ( ipconfigSUPPORT_SIGNALS != 0 )
  251. /* Send a signal to the task which is waiting for a given socket. */
  252. BaseType_t FreeRTOS_SignalSocket( Socket_t xSocket );
  253. /* Send a signal to the task which reads from this socket (FromISR
  254. * version). */
  255. BaseType_t FreeRTOS_SignalSocketFromISR( Socket_t xSocket,
  256. BaseType_t * pxHigherPriorityTaskWoken );
  257. #endif /* ipconfigSUPPORT_SIGNALS */
  258. /* Return the remote address and IP port. */
  259. BaseType_t FreeRTOS_GetRemoteAddress( ConstSocket_t xSocket,
  260. struct freertos_sockaddr * pxAddress );
  261. #if ( ipconfigUSE_TCP == 1 )
  262. /* Returns pdTRUE if TCP socket is connected. */
  263. BaseType_t FreeRTOS_issocketconnected( ConstSocket_t xSocket );
  264. /* Returns the actual size of MSS being used. */
  265. BaseType_t FreeRTOS_mss( ConstSocket_t xSocket );
  266. #endif /* ( ipconfigUSE_TCP == 1 ) */
  267. /* For internal use only: return the connection status. */
  268. BaseType_t FreeRTOS_connstatus( ConstSocket_t xSocket );
  269. /* Returns the number of bytes that may be added to txStream */
  270. BaseType_t FreeRTOS_maywrite( ConstSocket_t xSocket );
  271. /*
  272. * Two helper functions, mostly for testing
  273. * rx_size returns the number of bytes available in the Rx buffer
  274. * tx_space returns the free space in the Tx buffer
  275. */
  276. #if ( ipconfigUSE_TCP == 1 )
  277. BaseType_t FreeRTOS_rx_size( ConstSocket_t xSocket );
  278. BaseType_t FreeRTOS_tx_space( ConstSocket_t xSocket );
  279. BaseType_t FreeRTOS_tx_size( ConstSocket_t xSocket );
  280. #endif
  281. /* Returns the number of outstanding bytes in txStream. */
  282. /* The function FreeRTOS_outstanding() was already implemented
  283. * FreeRTOS_tx_size(). */
  284. #define FreeRTOS_outstanding( xSocket ) FreeRTOS_tx_size( xSocket )
  285. /* Returns the number of bytes in the socket's rxStream. */
  286. /* The function FreeRTOS_recvcount() was already implemented
  287. * FreeRTOS_rx_size(). */
  288. #define FreeRTOS_recvcount( xSocket ) FreeRTOS_rx_size( xSocket )
  289. /*
  290. * For advanced applications only:
  291. * Get a direct pointer to the circular transmit buffer.
  292. * '*pxLength' will contain the number of bytes that may be written.
  293. */
  294. uint8_t * FreeRTOS_get_tx_head( ConstSocket_t xSocket,
  295. BaseType_t * pxLength );
  296. #endif /* ipconfigUSE_TCP */
  297. #if ( ipconfigUSE_CALLBACKS != 0 )
  298. /*
  299. * Connect / disconnect handler for a TCP socket
  300. * For example:
  301. * static void vMyConnectHandler (Socket_t xSocket, BaseType_t ulConnected)
  302. * {
  303. * }
  304. * F_TCP_UDP_Handler_t xHnd = { vMyConnectHandler };
  305. * FreeRTOS_setsockopt( sock, 0, FREERTOS_SO_TCP_CONN_HANDLER, ( void * ) &xHnd, sizeof( xHnd ) );
  306. */
  307. #ifdef __COVERITY__
  308. typedef void (* FOnConnected_t )( Socket_t xSocket,
  309. BaseType_t ulConnected );
  310. #else
  311. typedef void (* FOnConnected_t )( Socket_t,
  312. BaseType_t );
  313. #endif
  314. /*
  315. * Reception handler for a TCP socket
  316. * A user-proved function will be called on reception of a message
  317. * If the handler returns a positive number, the messages will not be stored
  318. * For example:
  319. * static BaseType_t xOnTCPReceive( Socket_t xSocket, void * pData, size_t uxLength )
  320. * {
  321. * // handle the message
  322. * return 1;
  323. * }
  324. * F_TCP_UDP_Handler_t xHand = { xOnTCPReceive };
  325. * FreeRTOS_setsockopt( sock, 0, FREERTOS_SO_TCP_RECV_HANDLER, ( void * ) &xHand, sizeof( xHand ) );
  326. */
  327. #ifdef __COVERITY__
  328. typedef BaseType_t (* FOnTCPReceive_t )( Socket_t xSocket,
  329. void * pData,
  330. size_t xLength );
  331. typedef void (* FOnTCPSent_t )( Socket_t xSocket,
  332. size_t xLength );
  333. #else
  334. typedef BaseType_t (* FOnTCPReceive_t )( Socket_t,
  335. void *,
  336. size_t );
  337. typedef void (* FOnTCPSent_t )( Socket_t,
  338. size_t );
  339. #endif /* ifdef __COVERITY__ */
  340. /*
  341. * Reception handler for a UDP socket
  342. * A user-proved function will be called on reception of a message
  343. * If the handler returns a positive number, the messages will not be stored
  344. */
  345. #ifdef __COVERITY__
  346. typedef BaseType_t (* FOnUDPReceive_t ) ( Socket_t xSocket,
  347. void * pData,
  348. size_t xLength,
  349. const struct freertos_sockaddr * pxFrom,
  350. const struct freertos_sockaddr * pxDest );
  351. typedef void (* FOnUDPSent_t )( Socket_t xSocket,
  352. size_t xLength );
  353. #else
  354. typedef BaseType_t (* FOnUDPReceive_t ) ( Socket_t,
  355. void *,
  356. size_t,
  357. const struct freertos_sockaddr *,
  358. const struct freertos_sockaddr * );
  359. typedef void (* FOnUDPSent_t )( Socket_t,
  360. size_t );
  361. #endif /* ifdef __COVERITY__ */
  362. typedef union xTCP_UDP_HANDLER
  363. {
  364. FOnConnected_t pxOnTCPConnected; /* FREERTOS_SO_TCP_CONN_HANDLER */
  365. FOnTCPReceive_t pxOnTCPReceive; /* FREERTOS_SO_TCP_RECV_HANDLER */
  366. FOnTCPSent_t pxOnTCPSent; /* FREERTOS_SO_TCP_SENT_HANDLER */
  367. FOnUDPReceive_t pxOnUDPReceive; /* FREERTOS_SO_UDP_RECV_HANDLER */
  368. FOnUDPSent_t pxOnUDPSent; /* FREERTOS_SO_UDP_SENT_HANDLER */
  369. } F_TCP_UDP_Handler_t;
  370. #endif /* ( ipconfigUSE_CALLBACKS != 0 ) */
  371. BaseType_t FreeRTOS_setsockopt( Socket_t xSocket,
  372. int32_t lLevel,
  373. int32_t lOptionName,
  374. const void * pvOptionValue,
  375. size_t uxOptionLength );
  376. BaseType_t FreeRTOS_closesocket( Socket_t xSocket );
  377. /* The following function header should be placed in FreeRTOS_DNS.h.
  378. * It is kept here because some applications expect it in FreeRTOS_Sockets.h.*/
  379. #ifndef __COVERITY__
  380. uint32_t FreeRTOS_gethostbyname( const char * pcHostName );
  381. #endif
  382. BaseType_t FreeRTOS_inet_pton( BaseType_t xAddressFamily,
  383. const char * pcSource,
  384. void * pvDestination );
  385. const char * FreeRTOS_inet_ntop( BaseType_t xAddressFamily,
  386. const void * pvSource,
  387. char * pcDestination,
  388. socklen_t uxSize );
  389. /* Convert a null-terminated string in dot-decimal-notation (d.d.d.d) to a 32-bit unsigned integer. */
  390. uint32_t FreeRTOS_inet_addr( const char * pcIPAddress );
  391. BaseType_t FreeRTOS_inet_pton4( const char * pcSource,
  392. void * pvDestination );
  393. const char * FreeRTOS_inet_ntop4( const void * pvSource,
  394. char * pcDestination,
  395. socklen_t uxSize );
  396. /*
  397. * For the web server: borrow the circular Rx buffer for inspection
  398. * HTML driver wants to see if a sequence of 13/10/13/10 is available
  399. */
  400. const struct xSTREAM_BUFFER * FreeRTOS_get_rx_buf( ConstSocket_t xSocket );
  401. void FreeRTOS_netstat( void );
  402. #if ipconfigSUPPORT_SELECT_FUNCTION == 1
  403. /* For FD_SET and FD_CLR, a combination of the following bits can be used: */
  404. typedef enum eSELECT_EVENT
  405. {
  406. eSELECT_READ = 0x0001,
  407. eSELECT_WRITE = 0x0002,
  408. eSELECT_EXCEPT = 0x0004,
  409. eSELECT_INTR = 0x0008,
  410. eSELECT_ALL = 0x000F,
  411. /* Reserved for internal use: */
  412. eSELECT_CALL_IP = 0x0010,
  413. /* end */
  414. } eSelectEvent_t;
  415. SocketSet_t FreeRTOS_CreateSocketSet( void );
  416. void FreeRTOS_DeleteSocketSet( SocketSet_t xSocketSet );
  417. void FreeRTOS_FD_SET( Socket_t xSocket,
  418. SocketSet_t xSocketSet,
  419. EventBits_t xBitsToSet );
  420. void FreeRTOS_FD_CLR( Socket_t xSocket,
  421. SocketSet_t xSocketSet,
  422. EventBits_t xBitsToClear );
  423. EventBits_t FreeRTOS_FD_ISSET( Socket_t xSocket,
  424. SocketSet_t xSocketSet );
  425. BaseType_t FreeRTOS_select( SocketSet_t xSocketSet,
  426. TickType_t xBlockTimeTicks );
  427. #endif /* ipconfigSUPPORT_SELECT_FUNCTION */
  428. #ifdef __cplusplus
  429. } /* extern "C" */
  430. #endif
  431. #endif /* FREERTOS_SOCKETS_H */