[Thread] Implement write on socket interface

Bug: 313425570
Test: build pass & manual test
Change-Id: I2da14a563b795b0044362c1c248b53c1d3505d39
This commit is contained in:
shihchienc
2024-01-31 07:13:52 +00:00
parent 005f602d23
commit 5b2cd32368
2 changed files with 35 additions and 0 deletions

View File

@@ -83,6 +83,12 @@ void SocketInterface::Deinit(void) {
mReceiveFrameBuffer = nullptr;
}
otError SocketInterface::SendFrame(const uint8_t* aFrame, uint16_t aLength) {
Write(aFrame, aLength);
return OT_ERROR_NONE;
}
void SocketInterface::UpdateFdSet(void* aMainloopContext) {
otSysMainloopContext* context = reinterpret_cast<otSysMainloopContext*>(aMainloopContext);
@@ -95,6 +101,12 @@ void SocketInterface::UpdateFdSet(void* aMainloopContext) {
}
}
void SocketInterface::Write(const uint8_t* aFrame, uint16_t aLength) {
ssize_t rval = TEMP_FAILURE_RETRY(write(mSockFd, aFrame, aLength));
VerifyOrDie(rval >= 0, OT_EXIT_ERROR_ERRNO);
VerifyOrDie(rval > 0, OT_EXIT_FAILURE);
}
int SocketInterface::OpenFile(const ot::Url::Url& aRadioUrl) {
int fd = -1;
sockaddr_un serverAddress;