[udp] update Socket::Open() to include NetifId (#10964)

This commit updates how the `NetifId` is set on a `Udp::Socket`. It is
now specified as a parameter in the `Open()` call instead of `Bind()`.

This change makes the socket more flexible by allowing the `NetifId`
to be known earlier (which can be used for future optimizations). It
also allows the desired `NetifId` to be set even when `Bind()` is not
explicitly called, such as when `Connect()` or `SendTo()` are used on
a socket that is not yet bound. Previously, `kNetifThread` was
assumed by default in these situations.

The public `otUdp` APIs are left unchanged to ensure backward
compatibility.
This commit is contained in:
Abtin Keshavarzian
2024-11-26 11:18:53 -08:00
committed by GitHub
parent d347dd51e7
commit 65dd8bff66
15 changed files with 50 additions and 47 deletions
+2 -2
View File
@@ -1076,8 +1076,8 @@ void TestSrpClientDelayedResponse(void)
sServerRxCount = 0;
SuccessOrQuit(udpSocket.Open());
SuccessOrQuit(udpSocket.Bind(kServerPort, Ip6::kNetifThread));
SuccessOrQuit(udpSocket.Open(Ip6::kNetifThread));
SuccessOrQuit(udpSocket.Bind(kServerPort));
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Manually start the client with a message ID based on `testIter`