Commit b1d4150
authored
[posix] implement
This commit provides a complete POSIX implementation of the new
`otPlatTcp` platform abstraction APIs. It leverages the existing
OpenThread `Mainloop` polling mechanism to build a fully event-driven,
non-blocking TCP socket implementation without requiring extra threads.
Key features and implementation details:
- Uses `Mainloop` read/write/error sets to monitor socket states.
- Implements `otPlatTcpEnableListener` and `otPlatTcpAccept` to handle
incoming connection requests over IPv6.
- Implements `otPlatTcpConnect` for asynchronous non-blocking outgoing
TCP connections, monitoring `SO_ERROR` to detect handshake completion.
- Handles data transmission utilizing `otPlatTcpIsTxPending` to
monitor the write descriptor and correctly signal `HandleTxReady`.
- Implements `otPlatTcpSend` and `otPlatTcpReceive` ensuring proper
buffering, suppressing `SIGPIPE` safely using `SO_NOSIGPIPE` and
`MSG_NOSIGNAL`.
- Encodes socket file descriptors directly within the platform data
`mData.mDescriptor` union, avoiding dynamic memory allocation.otPlatTcp platform abstraction (openthread#13193)1 parent fcf7b4c commit b1d4150
5 files changed
Lines changed: 605 additions & 0 deletions
File tree
- src/posix/platform
- tests/toranj
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
155 | 156 | | |
156 | 157 | | |
157 | 158 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| |||
149 | 150 | | |
150 | 151 | | |
151 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
152 | 157 | | |
153 | 158 | | |
154 | 159 | | |
| |||
169 | 174 | | |
170 | 175 | | |
171 | 176 | | |
| 177 | + | |
172 | 178 | | |
173 | 179 | | |
174 | 180 | | |
| |||
248 | 254 | | |
249 | 255 | | |
250 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
251 | 261 | | |
252 | 262 | | |
253 | 263 | | |
| |||
310 | 320 | | |
311 | 321 | | |
312 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
313 | 327 | | |
314 | 328 | | |
315 | 329 | | |
| |||
341 | 355 | | |
342 | 356 | | |
343 | 357 | | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
344 | 363 | | |
345 | 364 | | |
346 | 365 | | |
| |||
0 commit comments