wolfSSL Manual

Docs -> wolfSSL Manual

Chapter 17: wolfSSL API Reference


17.9  DTLS Specific


The functions in this section are specific to using DTLS with wolfSSL.






CyaSSL_dtls


Synopsis:

#include <cyassl/ssl.h>


int CyaSSL_dtls(CYASSL* ssl);


Description:

This function is used to determine if the SSL session has been configured to use DTLS.


Return Values:

If the SSL session (ssl) has been configured to use DTLS, this function will return 1, otherwise 0.


Parameters:


ssl - a pointer to a CYASSL structure, created using CyaSSL_new().


Example:


int ret = 0;

CYASSL* ssl;

...


ret = CyaSSL_dtls(ssl);

if (ret) {

// SSL session has been configured to use DTLS

}


See Also:

CyaSSL_dtls_get_current_timeout

CyaSSL_dtls_get_peer

CyaSSL_dtls_got_timeout

CyaSSL_dtls_set_peer






CyaSSL_dtls_get_current_timeout


Synopsis:

#include <cyassl/ssl.h>


CyaSSL_dtls_get_current_timeout(CYASSL* ssl);


Description:

This function returns the current timeout value in seconds for the CYASSL object. When using non-blocking sockets, something in the user code needs to decide when to check for available recv data and how long it has been waiting. The value returned by this function indicates how long the application should wait.


Return Values:

The current DTLS timeout value in seconds, or NOT_COMPILED_IN if CyaSSL was not built with DTLS support.


Parameters:


ssl - a pointer to a CYASSL structure, created using CyaSSL_new().


Example:


int timeout = 0;

CYASSL* ssl;

...


timeout = CyaSSL_get_dtls_current_timeout(ssl);

printf(“DTLS timeout (sec) = %d\n”, timeout);


See Also:

CyaSSL_dtls

CyaSSL_dtls_get_peer

CyaSSL_dtls_got_timeout

CyaSSL_dtls_set_peer






CyaSSL_dtls_get_peer


Synopsis:

#include <cyassl/ssl.h>


int CyaSSL_dtls_get_peer(CYASSL* ssl, void* peer, unsigned int* peerSz);


Description:

This function gets the sockaddr_in (of size peerSz) of the current DTLS peer.  The function will compare peerSz to the actual DTLS peer size stored in the SSL session.  If the peer will fit into peer, the peer’s sockaddr_in will be copied into peer, with peerSz set to the size of peer.


Return Values:

SSL_SUCCESS will be returned upon success.


SSL_FAILURE will be returned upon failure.


SSL_NOT_IMPLEMENTED will be returned if CyaSSL was not compiled with DTLS support.


Parameters:


ssl - a pointer to a CYASSL structure, created using CyaSSL_new().


peer - pointer to memory location to store peer’s sockaddr_in structure.


peerSz - input/output size.  As input, the size of the allocated memory pointed to by peer.  As output, the size of the actual sockaddr_in structure pointed to by peer.


Example:


int ret = 0;

CYASSL* ssl;

sockaddr_in addr;

...


ret = CyaSSL_dtls_get_peer(ssl, &addr, sizeof(addr));

if (ret != SSL_SUCCESS) {

// failed to get DTLS peer

}


See Also:

CyaSSL_dtls_get_current_timeout

CyaSSL_dtls_got_timeout

CyaSSL_dtls_set_peer

CyaSSL_dtls






CyaSSL_dtls_got_timeout


Synopsis:

#include <cyassl/ssl.h>


int  CyaSSL_dtls_got_timeout(CYASSL* ssl);  


Description:

When using non-blocking sockets with DTLS, this function should be called on the CYASSL object when the controlling code thinks the transmission has timed out. It performs the actions needed to retry the last transmit, including adjusting the timeout value. If it has been too long, this will return a failure.


Return Values:

SSL_SUCCESS will be returned upon success


SSL_FATAL_ERROR will be returned if there have been too many retransmissions/timeouts without getting a response from the peer.


NOT_COMPILED_IN will be returned if CyaSSL was not compiled with DTLS support.


Parameters:


ssl - a pointer to a CYASSL structure, created using CyaSSL_new().


Example:


See the following files for usage examples:

<cyassl_root>/examples/client/client.c

<cyassl_root>/examples/server/server.c


See Also:

CyaSSL_dtls_get_current_timeout

CyaSSL_dtls_get_peer

CyaSSL_dtls_set_peer

CyaSSL_dtls






CyaSSL_dtls_set_peer


Synopsis:

#include <cyassl/ssl.h>


int CyaSSL_dtls_set_peer(CYASSL* ssl, void* peer, unsigned int peerSz);


Description:

This function sets the DTLS peer, peer (sockaddr_in) with size of peerSz.


Return Values:

SSL_SUCCESS will be returned upon success.


SSL_FAILURE will be returned upon failure.


SSL_NOT_IMPLEMENTED will be returned if CyaSSL was not compiled with DTLS support.


Parameters:


ssl - a pointer to a CYASSL structure, created using CyaSSL_new().


peer - pointer to peer’s sockaddr_in structure.


peerSz - size of the sockaddr_in structure pointed to by peer.


Example:


int ret = 0;

CYASSL* ssl;

sockaddr_in addr;

...


ret = CyaSSL_dtls_set_peer(ssl, &addr, sizeof(addr));

if (ret != SSL_SUCCESS) {

// failed to set DTLS peer

}


See Also:

CyaSSL_dtls_get_current_timeout

CyaSSL_dtls_get_peer

CyaSSL_dtls_got_timeout

CyaSSL_dtls




 

Questions? +1 (425) 245-8247