Adapt prototype of net_accept() for explicit size
diff --git a/include/mbedtls/error.h b/include/mbedtls/error.h
index c3b0b15..3dd90a9 100644
--- a/include/mbedtls/error.h
+++ b/include/mbedtls/error.h
@@ -62,7 +62,7 @@
* DES 1 0x0032-0x0032
* CTR_DBRG 4 0x0034-0x003A
* ENTROPY 3 0x003C-0x0040
- * NET 9 0x0042-0x0052
+ * NET 9 0x0042-0x0052 0x0043-0x0043
* ENTROPY 1 0x0058-0x0058
* ASN1 7 0x0060-0x006C
* MD2 1 0x0070-0x0070
diff --git a/include/mbedtls/net.h b/include/mbedtls/net.h
index 586ee0b..55db27d 100644
--- a/include/mbedtls/net.h
+++ b/include/mbedtls/net.h
@@ -44,6 +44,7 @@
#define MBEDTLS_ERR_NET_SEND_FAILED -0x004E /**< Sending information through the socket failed. */
#define MBEDTLS_ERR_NET_CONN_RESET -0x0050 /**< Connection was reset by peer. */
#define MBEDTLS_ERR_NET_UNKNOWN_HOST -0x0052 /**< Failed to get an IP address for the given hostname. */
+#define MBEDTLS_ERR_NET_BUFFER_TOO_SMALL -0x0043 /**< Buffer is too small to hold the data. */
#define MBEDTLS_NET_LISTEN_BACKLOG 10 /**< The backlog that listen() should use. */
@@ -96,17 +97,21 @@
* \param bind_fd Relevant socket
* \param client_fd Will contain the connected client socket
* \param client_ip Will contain the client IP address
- * Must be at least 4 bytes, or 16 if IPv6 is supported
+ * \param buf_size Size of the client_ip buffer
+ * \param ip_len Will receive the size of the client IP written
*
- * \return 0 if successful, MBEDTLS_ERR_NET_ACCEPT_FAILED, or
- * MBEDTLS_ERR_SSL_WANT_READ is bind_fd was set to
+ * \return 0 if successful, or
+ * MBEDTLS_ERR_NET_ACCEPT_FAILED, or
+ * MBEDTLS_ERR_NET_BUFFER_TOO_SMALL if buf_size is too small,
+ * MBEDTLS_ERR_SSL_WANT_READ if bind_fd was set to
* non-blocking and accept() is blocking.
*
* \note With UDP, connects the bind_fd to the client and just copy
* its descriptor to client_fd. New clients will not be able
* to connect until you close the socket and bind a new one.
*/
-int mbedtls_net_accept( int bind_fd, int *client_fd, void *client_ip );
+int mbedtls_net_accept( int bind_fd, int *client_fd,
+ void *client_ip, size_t buf_size, size_t *ip_len );
/**
* \brief Set the socket blocking