mirror of
https://github.com/espressif/openthread.git
synced 2026-08-17 16:09:51 +00:00
[dtls] cleanup method names (#3694)
- Rename Close() to Disconnect() to better pair with Connect() - Rename Stop() to Close() to better pair with Open() - Make Setup() private.
This commit is contained in:
committed by
Jonathan Hui
parent
a39f2c86d3
commit
c0de3be7f3
@@ -93,7 +93,7 @@ void CoapSecure::SetConnectedCallback(ConnectedCallback aCallback, void *aContex
|
||||
|
||||
void CoapSecure::Stop(void)
|
||||
{
|
||||
mDtls.Stop();
|
||||
mDtls.Close();
|
||||
|
||||
for (ot::Message *message = mTransmitQueue.GetHead(); message != NULL; message = message->GetNext())
|
||||
{
|
||||
|
||||
@@ -138,7 +138,7 @@ public:
|
||||
* This method stops the DTLS connection.
|
||||
*
|
||||
*/
|
||||
void Disconnect(void) { mDtls.Close(); }
|
||||
void Disconnect(void) { mDtls.Disconnect(); }
|
||||
|
||||
/**
|
||||
* This method returns a reference to the DTLS object.
|
||||
|
||||
+10
-10
@@ -457,9 +457,9 @@ void Dtls::SetSslAuthMode(bool aVerifyPeerCertificate)
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
|
||||
void Dtls::Stop(void)
|
||||
void Dtls::Close(void)
|
||||
{
|
||||
Close();
|
||||
Disconnect();
|
||||
|
||||
mState = kStateClosed;
|
||||
mTransportCallback = NULL;
|
||||
@@ -470,7 +470,7 @@ void Dtls::Stop(void)
|
||||
mTimer.Stop();
|
||||
}
|
||||
|
||||
void Dtls::Close(void)
|
||||
void Dtls::Disconnect(void)
|
||||
{
|
||||
VerifyOrExit(mState == kStateConnecting || mState == kStateConnected);
|
||||
|
||||
@@ -854,7 +854,7 @@ void Dtls::HandleTimer(void)
|
||||
void Dtls::Process(void)
|
||||
{
|
||||
uint8_t buf[MBEDTLS_SSL_MAX_CONTENT_LEN];
|
||||
bool shouldClose = false;
|
||||
bool shouldDisconnect = false;
|
||||
int rval;
|
||||
|
||||
while ((mState == kStateConnecting) || (mState == kStateConnected))
|
||||
@@ -892,7 +892,7 @@ void Dtls::Process(void)
|
||||
{
|
||||
case MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY:
|
||||
mbedtls_ssl_close_notify(&mSsl);
|
||||
ExitNow(shouldClose = true);
|
||||
ExitNow(shouldDisconnect = true);
|
||||
break;
|
||||
|
||||
case MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED:
|
||||
@@ -900,7 +900,7 @@ void Dtls::Process(void)
|
||||
|
||||
case MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE:
|
||||
mbedtls_ssl_close_notify(&mSsl);
|
||||
ExitNow(shouldClose = true);
|
||||
ExitNow(shouldDisconnect = true);
|
||||
break;
|
||||
|
||||
case MBEDTLS_ERR_SSL_INVALID_MAC:
|
||||
@@ -908,7 +908,7 @@ void Dtls::Process(void)
|
||||
{
|
||||
mbedtls_ssl_send_alert_message(&mSsl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
|
||||
MBEDTLS_SSL_ALERT_MSG_BAD_RECORD_MAC);
|
||||
ExitNow(shouldClose = true);
|
||||
ExitNow(shouldDisconnect = true);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -918,7 +918,7 @@ void Dtls::Process(void)
|
||||
{
|
||||
mbedtls_ssl_send_alert_message(&mSsl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
|
||||
MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE);
|
||||
ExitNow(shouldClose = true);
|
||||
ExitNow(shouldDisconnect = true);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -935,9 +935,9 @@ void Dtls::Process(void)
|
||||
|
||||
exit:
|
||||
|
||||
if (shouldClose)
|
||||
if (shouldDisconnect)
|
||||
{
|
||||
Close();
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+26
-40
@@ -153,42 +153,12 @@ public:
|
||||
*/
|
||||
otError Open(ReceiveHandler aReceiveHandler, ConnectedHandler aConnectedHandler, void *aContext);
|
||||
|
||||
/**
|
||||
* This method starts the DTLS service.
|
||||
*
|
||||
* For CoAP Secure API do first:
|
||||
* Set X509 Pk and Cert for use DTLS mode ECDHE ECDSA with AES 128 CCM 8 or
|
||||
* set PreShared Key for use DTLS mode PSK with AES 128 CCM 8.
|
||||
*
|
||||
* @param[in] aSockAddr A reference to the remote sockaddr.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started the DTLS service.
|
||||
* @retval OT_ERROR_INVALID_STATE The DTLS service is not in state kStateOpen.
|
||||
*
|
||||
*/
|
||||
otError Connect(const Ip6::SockAddr &aSockAddr);
|
||||
|
||||
/**
|
||||
* This method set up the DTLS service.
|
||||
*
|
||||
* For CoAP Secure API do first:
|
||||
* Set X509 Pk and Cert for use DTLS mode ECDHE ECDSA with AES 128 CCM 8 or
|
||||
* set PreShared Key for use DTLS mode PSK with AES 128 CCM 8.
|
||||
*
|
||||
* @param[in] aClient TRUE if setup for client, otherwise setup for server.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started the DTLS service.
|
||||
* @retval OT_ERROR_INVALID_STATE The DTLS service is not in state kStateClosed.
|
||||
*
|
||||
*/
|
||||
otError Setup(bool aClient);
|
||||
|
||||
/**
|
||||
* This method binds this DTLS to a UDP port.
|
||||
*
|
||||
* @param[in] aPort The port to bind.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully binded the DTLS service.
|
||||
* @retval OT_ERROR_NONE Successfully bound the DTLS socket.
|
||||
* @retval OT_ERROR_INVALID_STATE The DTLS service is not in state kStateOpen.
|
||||
* @retval OT_ERROR_ALREADY Already bound.
|
||||
*
|
||||
@@ -201,13 +171,28 @@ public:
|
||||
* @param[in] aCallback A pointer to a function for sending messages.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully binded the DTLS service.
|
||||
* @retval OT_ERROR_NONE Successfully bound the DTLS socket.
|
||||
* @retval OT_ERROR_INVALID_STATE The DTLS service is not in state kStateOpen.
|
||||
* @retval OT_ERROR_ALREADY Already bound.
|
||||
*
|
||||
*/
|
||||
otError Bind(TransportCallback aCallback, void *aContext);
|
||||
|
||||
/**
|
||||
* This method establishes a DTLS session.
|
||||
*
|
||||
* For CoAP Secure API do first:
|
||||
* Set X509 Pk and Cert for use DTLS mode ECDHE ECDSA with AES 128 CCM 8 or
|
||||
* set PreShared Key for use DTLS mode PSK with AES 128 CCM 8.
|
||||
*
|
||||
* @param[in] aSockAddr A reference to the remote sockaddr.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started DTLS handshake.
|
||||
* @retval OT_ERROR_INVALID_STATE The DTLS service is not in state kStateOpen.
|
||||
*
|
||||
*/
|
||||
otError Connect(const Ip6::SockAddr &aSockAddr);
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the DTLS session is active.
|
||||
*
|
||||
@@ -231,17 +216,17 @@ public:
|
||||
bool IsConnected(void) const { return mState == kStateConnected; }
|
||||
|
||||
/**
|
||||
* This method close the current session.
|
||||
* This method disconnects the DTLS session.
|
||||
*
|
||||
*/
|
||||
void Disconnect(void);
|
||||
|
||||
/**
|
||||
* This method closes the DTLS socket.
|
||||
*
|
||||
*/
|
||||
void Close(void);
|
||||
|
||||
/**
|
||||
* This method stops the DTLS service.
|
||||
*
|
||||
*/
|
||||
void Stop(void);
|
||||
|
||||
/**
|
||||
* This method returns the DTLS connection state.
|
||||
*
|
||||
@@ -414,7 +399,8 @@ public:
|
||||
void HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
|
||||
|
||||
private:
|
||||
void FreeMbedtls(void);
|
||||
void FreeMbedtls(void);
|
||||
otError Setup(bool aClient);
|
||||
|
||||
static otError MapError(int rval);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user