mirror of
https://github.com/espressif/openthread.git
synced 2026-07-28 14:47:46 +00:00
[secure-transport] reorder member variables to avoid alignment gaps (#10946)
This commit reorders the member variables in `SecureTransport`, grouping booleans and variables of the same size closer to each other to avoid alignment gaps and allow for better code optimization.
This commit is contained in:
@@ -74,20 +74,21 @@ const int SecureTransport::kCipherSuites[][2] = {
|
||||
|
||||
SecureTransport::SecureTransport(Instance &aInstance, LinkSecurityMode aLayerTwoSecurity, bool aDatagramTransport)
|
||||
: InstanceLocator(aInstance)
|
||||
, mState(kStateClosed)
|
||||
, mCipherSuite(kUnspecifiedCipherSuite)
|
||||
, mPskLength(0)
|
||||
, mVerifyPeerCertificate(true)
|
||||
, mTimer(aInstance, SecureTransport::HandleTimer, this)
|
||||
, mTimerIntermediate(0)
|
||||
, mTimerSet(false)
|
||||
, mLayerTwoSecurity(aLayerTwoSecurity)
|
||||
, mDatagramTransport(aDatagramTransport)
|
||||
, mTimerSet(false)
|
||||
, mVerifyPeerCertificate(true)
|
||||
, mState(kStateClosed)
|
||||
, mCipherSuite(kUnspecifiedCipherSuite)
|
||||
, mMessageSubType(Message::kSubTypeNone)
|
||||
, mConnectEvent(kDisconnectedError)
|
||||
, mPskLength(0)
|
||||
, mMaxConnectionAttempts(0)
|
||||
, mRemainingConnectionAttempts(0)
|
||||
, mReceiveMessage(nullptr)
|
||||
, mSocket(aInstance, *this)
|
||||
, mMessageSubType(Message::kSubTypeNone)
|
||||
, mTimer(aInstance, SecureTransport::HandleTimer, this)
|
||||
, mTimerIntermediate(0)
|
||||
{
|
||||
ClearAllBytes(mPsk);
|
||||
ClearAllBytes(mSsl);
|
||||
|
||||
@@ -605,54 +605,38 @@ private:
|
||||
|
||||
static const int kCipherSuites[][2];
|
||||
|
||||
State mState;
|
||||
CipherSuite mCipherSuite;
|
||||
|
||||
uint8_t mPsk[kPskMaxLength];
|
||||
uint8_t mPskLength;
|
||||
|
||||
#if OPENTHREAD_CONFIG_TLS_API_ENABLE && defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
|
||||
EcdheEcdsaInfo mEcdheEcdsaInfo;
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_TLS_API_ENABLE && defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED)
|
||||
PskInfo mPskInfo;
|
||||
#endif
|
||||
|
||||
bool mVerifyPeerCertificate;
|
||||
|
||||
mbedtls_ssl_context mSsl;
|
||||
mbedtls_ssl_config mConf;
|
||||
|
||||
bool mLayerTwoSecurity : 1;
|
||||
bool mDatagramTransport : 1;
|
||||
bool mTimerSet : 1;
|
||||
bool mVerifyPeerCertificate : 1;
|
||||
State mState;
|
||||
CipherSuite mCipherSuite;
|
||||
Message::SubType mMessageSubType;
|
||||
ConnectEvent mConnectEvent;
|
||||
uint8_t mPskLength;
|
||||
uint16_t mMaxConnectionAttempts;
|
||||
uint16_t mRemainingConnectionAttempts;
|
||||
Message *mReceiveMessage;
|
||||
Ip6::MessageInfo mMessageInfo;
|
||||
TransportSocket mSocket;
|
||||
uint8_t mPsk[kPskMaxLength];
|
||||
TimerMilliContext mTimer;
|
||||
TimeMilli mTimerIntermediate;
|
||||
Callback<AutoCloseCallback> mAutoCloseCallback;
|
||||
Callback<ConnectedHandler> mConnectedCallback;
|
||||
Callback<ReceiveHandler> mReceiveCallback;
|
||||
Callback<TransportCallback> mTransportCallback;
|
||||
mbedtls_ssl_context mSsl;
|
||||
mbedtls_ssl_config mConf;
|
||||
#if defined(MBEDTLS_SSL_SRV_C) && defined(MBEDTLS_SSL_COOKIE_C)
|
||||
mbedtls_ssl_cookie_ctx mCookieCtx;
|
||||
#endif
|
||||
|
||||
TimerMilliContext mTimer;
|
||||
|
||||
TimeMilli mTimerIntermediate;
|
||||
bool mTimerSet : 1;
|
||||
|
||||
bool mLayerTwoSecurity : 1;
|
||||
bool mDatagramTransport : 1;
|
||||
|
||||
uint16_t mMaxConnectionAttempts;
|
||||
uint16_t mRemainingConnectionAttempts;
|
||||
Callback<AutoCloseCallback> mAutoCloseCallback;
|
||||
|
||||
Message *mReceiveMessage;
|
||||
|
||||
Callback<ConnectedHandler> mConnectedCallback;
|
||||
Callback<ReceiveHandler> mReceiveCallback;
|
||||
|
||||
Ip6::MessageInfo mMessageInfo;
|
||||
TransportSocket mSocket;
|
||||
|
||||
Callback<TransportCallback> mTransportCallback;
|
||||
|
||||
Message::SubType mMessageSubType;
|
||||
|
||||
ConnectEvent mConnectEvent;
|
||||
#if OPENTHREAD_CONFIG_TLS_API_ENABLE && defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
|
||||
EcdheEcdsaInfo mEcdheEcdsaInfo;
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_TLS_API_ENABLE && defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED)
|
||||
PskInfo mPskInfo;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace MeshCoP
|
||||
|
||||
Reference in New Issue
Block a user