From 7f2828657a8254f722cc8a970a96ea479f2d8a60 Mon Sep 17 00:00:00 2001 From: Cristian Bulacu <127317648+Cristib05@users.noreply.github.com> Date: Thu, 13 Mar 2025 17:31:48 +0200 Subject: [PATCH] [secure-transport] Add option to specify NetifIdentifier (#11338) This commit aims to add the possibility to specify a netif identifier for SecureTransport::Open method. This method has now a default parameter, kNetifUnspecified, if no argument is explicitly passed by the user. Signed-off-by: Cristian Bulacu --- src/core/meshcop/joiner.cpp | 2 +- src/core/meshcop/secure_transport.cpp | 4 ++-- src/core/meshcop/secure_transport.hpp | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/meshcop/joiner.cpp b/src/core/meshcop/joiner.cpp index 0173940aa..78d1d6fa8 100644 --- a/src/core/meshcop/joiner.cpp +++ b/src/core/meshcop/joiner.cpp @@ -137,7 +137,7 @@ Error Joiner::Start(const char *aPskd, Get().SetExtAddress(randomAddress); Get().UpdateLinkLocalAddress(); - SuccessOrExit(error = Get().Open()); + SuccessOrExit(error = Get().Open(Ip6::NetifIdentifier::kNetifThreadInternal)); SuccessOrExit(error = Get().Bind(kJoinerUdpPort)); Get().SetConnectCallback(HandleSecureCoapClientConnect, this); Get().SetPsk(joinerPskd); diff --git a/src/core/meshcop/secure_transport.cpp b/src/core/meshcop/secure_transport.cpp index 3ac1c89d0..a9546ad81 100644 --- a/src/core/meshcop/secure_transport.cpp +++ b/src/core/meshcop/secure_transport.cpp @@ -676,13 +676,13 @@ SecureTransport::SecureTransport(Instance &aInstance, LinkSecurityMode aLayerTwo OT_UNUSED_VARIABLE(mVerifyPeerCertificate); } -Error SecureTransport::Open(void) +Error SecureTransport::Open(Ip6::NetifIdentifier aNetifIdentifier) { Error error; VerifyOrExit(!mIsOpen, error = kErrorAlready); - SuccessOrExit(error = mSocket.Open(Ip6::kNetifUnspecified)); + SuccessOrExit(error = mSocket.Open(aNetifIdentifier)); mIsOpen = true; mRemainingConnectionAttempts = mMaxConnectionAttempts; diff --git a/src/core/meshcop/secure_transport.hpp b/src/core/meshcop/secure_transport.hpp index 63eb40444..5e2c14f0e 100644 --- a/src/core/meshcop/secure_transport.hpp +++ b/src/core/meshcop/secure_transport.hpp @@ -592,10 +592,13 @@ public: /** * Opens the transport. * + * @param[in] aNetifIdentifier A network interface identifier. If not explicitly provided, kNetifUnspecified will + * be used by default. + * * @retval kErrorNone Successfully opened the socket. * @retval kErrorAlready The connection is already open. */ - Error Open(void); + Error Open(Ip6::NetifIdentifier aNetifIdentifier = Ip6::NetifIdentifier::kNetifUnspecified); /** * Sets the maximum number of allowed connection requests before socket is automatically closed.