mirror of
https://github.com/espressif/openthread.git
synced 2026-09-10 03:00:09 +00:00
[platform] define otPlatTcp platform abstraction APIs (#13175)
This commit introduces a new platform abstraction layer for TCP connections and listeners, enabling OpenThread to leverage platform- provided TCP stacks. The API is designed for asynchronous, event-driven environments and can easily support POSIX as well as various embedded network stacks. In the core, `Ip6::PlatTcp` and its nested `Connection` and `Listener` classes are introduced to manage these platform interactions, providing a clean C++ interface for the OpenThread core. The `PlatTcp` manager is integrated into the `Instance` class and utilizes `Tasklet` for asynchronous resource cleanup. Additionally, this commit adds a comprehensive unit test to verify the TCP platform abstraction and `Ip6::PlatTcp` implementation. The tests cover listener and connection lifecycles, data flow, flow control, incoming connection acceptance, and active object iteration.
This commit is contained in:
@@ -658,6 +658,46 @@ OT_TOOL_WEAK void otPlatMdnsSendUnicast(otInstance *aInstance,
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_TCP_ENABLE
|
||||
|
||||
OT_TOOL_WEAK otError otPlatTcpEnableListener(otPlatTcpListener *aListener, const otPlatTcpSockAddr *aLocalSockAddr)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aListener);
|
||||
OT_UNUSED_VARIABLE(aLocalSockAddr);
|
||||
|
||||
return OT_ERROR_FAILED;
|
||||
}
|
||||
|
||||
OT_TOOL_WEAK void otPlatTcpDisableListener(otPlatTcpListener *aListener) { OT_UNUSED_VARIABLE(aListener); }
|
||||
|
||||
OT_TOOL_WEAK otError otPlatTcpConnect(otPlatTcpConnection *aConn,
|
||||
const otPlatTcpSockAddr *aPeerSockAddr,
|
||||
const otPlatTcpSockAddr *aLocalSockAddr)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aConn);
|
||||
OT_UNUSED_VARIABLE(aPeerSockAddr);
|
||||
OT_UNUSED_VARIABLE(aLocalSockAddr);
|
||||
|
||||
return OT_ERROR_FAILED;
|
||||
}
|
||||
|
||||
OT_TOOL_WEAK void otPlatTcpNotifyTxPending(otPlatTcpConnection *aConn) { OT_UNUSED_VARIABLE(aConn); }
|
||||
|
||||
OT_TOOL_WEAK uint16_t otPlatTcpSend(otPlatTcpConnection *aConn, const uint8_t *aBuffer, uint16_t aLength)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aConn);
|
||||
OT_UNUSED_VARIABLE(aBuffer);
|
||||
OT_UNUSED_VARIABLE(aLength);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
OT_TOOL_WEAK void otPlatTcpClose(otPlatTcpConnection *aConn) { OT_UNUSED_VARIABLE(aConn); }
|
||||
|
||||
OT_TOOL_WEAK void otPlatTcpAbort(otPlatTcpConnection *aConn) { OT_UNUSED_VARIABLE(aConn); }
|
||||
|
||||
#endif // #if OPENTHREAD_CONFIG_PLATFORM_TCP_ENABLE
|
||||
|
||||
#if OPENTHREAD_CONFIG_DNS_DSO_ENABLE
|
||||
|
||||
OT_TOOL_WEAK void otPlatDsoEnableListening(otInstance *aInstance, bool aEnable)
|
||||
|
||||
Reference in New Issue
Block a user