[udp] add kNetifThreadInternal which disallows platform UDP use (#10965)

This commit introduces `kNetifThreadInternal` as a network interface
option for UDP sockets. Unlike other options, this disallows the use
of platform UDP for the socket, indicating that the socket should use
the OpenThread internal Thread network interface only.

This model replaces the previous approach where `ShouldUsePlatformUdp()`
would check the socket port against a set of port numbers used by
different modules (such as MLE, TMF, Joiner Router, etc) to determine
whether platform UDP APIs should be used. With the new model, each
module decides whether to associate its socket with the
`kNetifThreadInternal`.

This is a more flexible and extensible model, ensuring that sockets
that should not use the platform do not waste resources (they will
not be created or opened/closed on the platform). This also help
avoid edge cases where platform UDP operations may unintentionally
fail when the platform socket is not actually needed.
This commit is contained in:
Abtin Keshavarzian
2024-11-28 08:58:19 -08:00
committed by GitHub
parent ae5b750d30
commit 473af53155
16 changed files with 113 additions and 78 deletions
+1 -1
View File
@@ -1076,7 +1076,7 @@ void TestSrpClientDelayedResponse(void)
sServerRxCount = 0;
SuccessOrQuit(udpSocket.Open(Ip6::kNetifThread));
SuccessOrQuit(udpSocket.Open(Ip6::kNetifThreadHost));
SuccessOrQuit(udpSocket.Bind(kServerPort));
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -