mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-01-28 03:12:20 +01:00
Merge pull request #5284 from julek-wolfssl/dtls-good-ch-cb
DTLS 1.3: additions for event driven server in wolfssl-examples
This commit is contained in:
@@ -1595,7 +1595,87 @@ WOLFSSL* wolfSSL_new(WOLFSSL_CTX*);
|
||||
\sa wolfSSL_SetIOReadCtx
|
||||
\sa wolfSSL_SetIOWriteCtx
|
||||
*/
|
||||
int wolfSSL_set_fd (WOLFSSL* ssl, int fd);
|
||||
int wolfSSL_set_fd(WOLFSSL* ssl, int fd);
|
||||
|
||||
/*!
|
||||
\ingroup Setup
|
||||
|
||||
\brief This function assigns a file descriptor (fd) as the
|
||||
input/output facility for the SSL connection. Typically this will be
|
||||
a socket file descriptor. This is a DTLS specific API because it marks that
|
||||
the socket is connected. recvfrom and sendto calls on this fd will have the
|
||||
addr and addr_len parameters set to NULL.
|
||||
|
||||
\return SSL_SUCCESS upon success.
|
||||
\return Bad_FUNC_ARG upon failure.
|
||||
|
||||
\param ssl pointer to the SSL session, created with wolfSSL_new().
|
||||
\param fd file descriptor to use with SSL/TLS connection.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int sockfd;
|
||||
WOLFSSL* ssl = 0;
|
||||
...
|
||||
if (connect(sockfd, peer_addr, peer_addr_len) != 0) {
|
||||
// handle connect error
|
||||
}
|
||||
...
|
||||
ret = wolfSSL_set_dtls_fd_connected(ssl, sockfd);
|
||||
if (ret != SSL_SUCCESS) {
|
||||
// failed to set SSL file descriptor
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_CTX_SetIOSend
|
||||
\sa wolfSSL_CTX_SetIORecv
|
||||
\sa wolfSSL_SetIOReadCtx
|
||||
\sa wolfSSL_SetIOWriteCtx
|
||||
\sa wolfDTLS_SetChGoodCb
|
||||
*/
|
||||
int wolfSSL_set_dtls_fd_connected(WOLFSSL* ssl, int fd)
|
||||
|
||||
/*!
|
||||
\ingroup Setup
|
||||
|
||||
\brief Allows setting a callback for a correctly processed and verified DTLS
|
||||
client hello. When using a cookie exchange mechanism (either the
|
||||
HelloVerifyRequest in DTLS 1.2 or the HelloRetryRequest with a cookie
|
||||
extension in DTLS 1.3) this callback is called after the cookie
|
||||
exchange has succeeded. This is useful to use one WOLFSSL object as
|
||||
the listener for new connections and being able to isolate the
|
||||
WOLFSSL object once the ClientHello is verified (either through a
|
||||
cookie exchange or just checking if the ClientHello had the correct
|
||||
format).
|
||||
DTLS 1.2:
|
||||
https://datatracker.ietf.org/doc/html/rfc6347#section-4.2.1
|
||||
DTLS 1.3:
|
||||
https://www.rfc-editor.org/rfc/rfc8446#section-4.2.2
|
||||
|
||||
\return SSL_SUCCESS upon success.
|
||||
\return BAD_FUNC_ARG upon failure.
|
||||
|
||||
\param ssl pointer to the SSL session, created with wolfSSL_new().
|
||||
\param fd file descriptor to use with SSL/TLS connection.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
|
||||
// Called when we have verified a connection
|
||||
static int chGoodCb(WOLFSSL* ssl, void* arg)
|
||||
{
|
||||
// setup peer and file descriptors
|
||||
|
||||
}
|
||||
|
||||
if (wolfDTLS_SetChGoodCb(ssl, chGoodCb, NULL) != WOLFSSL_SUCCESS) {
|
||||
// error setting callback
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_set_dtls_fd_connected
|
||||
*/
|
||||
int wolfDTLS_SetChGoodCb(WOLFSSL* ssl, ClientHelloGoodCb cb, void* user_ctx);
|
||||
|
||||
/*!
|
||||
\ingroup IO
|
||||
@@ -3521,9 +3601,11 @@ int wolfSSL_dtls(WOLFSSL* ssl);
|
||||
\return SSL_NOT_IMPLEMENTED will be returned if wolfSSL was not compiled
|
||||
with DTLS support.
|
||||
|
||||
\param ssl a pointer to a WOLFSSL structure, created using wolfSSL_new().
|
||||
\param peer pointer to peer’s sockaddr_in structure.
|
||||
\param peerSz size of the sockaddr_in structure pointed to by peer.
|
||||
\param ssl a pointer to a WOLFSSL structure, created using wolfSSL_new().
|
||||
\param peer pointer to peer’s sockaddr_in structure. If NULL then the peer
|
||||
information in ssl is cleared.
|
||||
\param peerSz size of the sockaddr_in structure pointed to by peer. If 0
|
||||
then the peer information in ssl is cleared.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
|
||||
Reference in New Issue
Block a user