Skip to content

Commit

Permalink
[Inet] InetIterator::GetHardwareAddress for LwIP (#12687)
Browse files Browse the repository at this point in the history
* [Inet] InetIterator::GetHardwareAddress for LwIP

#### Problem

1b24137 (#12552) added `InetIterator::GetHardwareAddress()`,
with an implementation for Zephyr and stubs for other builds.

#### Change overview

Implement `GetHardwareAddress()` for LwIP builds.

(For sockets builds, there is no cross-platform access to the
hardware MAC. Linux could use `SIOCGIFHWADDR`.)

#### Testing

CI (test from #12552)

* fix buffer size check
  • Loading branch information
kpschoedel authored and pull[bot] committed Apr 27, 2022
1 parent 2da3e83 commit 1bb28b6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/inet/InetInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ CHIP_ERROR InterfaceIterator::GetInterfaceType(InterfaceType & type)

CHIP_ERROR InterfaceIterator::GetHardwareAddress(uint8_t * addressBuffer, uint8_t & addressSize, uint8_t addressBufferSize)
{
return CHIP_ERROR_NOT_IMPLEMENTED;
VerifyOrReturnError(addressBuffer != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(HasCurrent(), CHIP_ERROR_INCORRECT_STATE);
VerifyOrReturnError(addressBufferSize >= mCurNetif->hwaddr_len, CHIP_ERROR_BUFFER_TOO_SMALL);
addressSize = mCurNetif->hwaddr_len;
memcpy(addressBuffer, mCurNetif->hwaddr, addressSize);
return CHIP_NO_ERROR;
}

bool InterfaceAddressIterator::HasCurrent()
Expand Down

0 comments on commit 1bb28b6

Please sign in to comment.