[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 <[email protected]>
This commit is contained in:
Cristian Bulacu
2025-03-13 08:31:48 -07:00
committed by GitHub
parent 4c0af02513
commit 7f2828657a
3 changed files with 7 additions and 4 deletions
+1 -1
View File
@@ -137,7 +137,7 @@ Error Joiner::Start(const char *aPskd,
Get<Mac::Mac>().SetExtAddress(randomAddress);
Get<Mle::MleRouter>().UpdateLinkLocalAddress();
SuccessOrExit(error = Get<Tmf::SecureAgent>().Open());
SuccessOrExit(error = Get<Tmf::SecureAgent>().Open(Ip6::NetifIdentifier::kNetifThreadInternal));
SuccessOrExit(error = Get<Tmf::SecureAgent>().Bind(kJoinerUdpPort));
Get<Tmf::SecureAgent>().SetConnectCallback(HandleSecureCoapClientConnect, this);
Get<Tmf::SecureAgent>().SetPsk(joinerPskd);
+2 -2
View File
@@ -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;
+4 -1
View File
@@ -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.