Skip to content

Commit c1ae85c

Browse files
[Silabs] remove lwipopts-thread.h. (#32002)
* remove lwipopts-thread.h. LWIP is not using with our thread implementation * Fix to build efr32 test driver with openthread Inet endpoint instead of lwip (so it uses the same config as our sample apps). Add to implement additional InetInterface method that were missing for the openthread inet endpoint interface. Make TestInetAddress.cpp work for CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
1 parent d8f5bf1 commit c1ae85c

File tree

7 files changed

+79
-202
lines changed

7 files changed

+79
-202
lines changed

src/inet/InetInterface.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,23 @@ bool InterfaceIterator::Next()
113113
return false;
114114
}
115115

116+
CHIP_ERROR InterfaceIterator::GetInterfaceName(char * nameBuf, size_t nameBufSize)
117+
{
118+
VerifyOrReturnError(HasCurrent(), CHIP_ERROR_INCORRECT_STATE);
119+
return InterfaceId(1).GetInterfaceName(nameBuf, nameBufSize);
120+
}
121+
122+
InterfaceId InterfaceIterator::GetInterfaceId()
123+
{
124+
// only 1 interface is supported
125+
return HasCurrent() ? InterfaceId(1) : InterfaceId::Null();
126+
}
127+
128+
bool InterfaceIterator::IsUp()
129+
{
130+
return HasCurrent() && (otThreadGetDeviceRole(Inet::globalOtInstance) != OT_DEVICE_ROLE_DISABLED);
131+
}
132+
116133
InterfaceAddressIterator::InterfaceAddressIterator()
117134
{
118135
mNetifAddrList = nullptr;
@@ -128,6 +145,8 @@ bool InterfaceAddressIterator::Next()
128145
{
129146
if (mNetifAddrList == nullptr)
130147
{
148+
if (Inet::globalOtInstance == nullptr)
149+
return false;
131150
mNetifAddrList = otIp6GetUnicastAddresses(Inet::globalOtInstance);
132151
mCurAddr = mNetifAddrList;
133152
}
@@ -155,6 +174,22 @@ uint8_t InterfaceAddressIterator::GetPrefixLength()
155174
return 64;
156175
}
157176

177+
bool InterfaceAddressIterator::IsUp()
178+
{
179+
return HasCurrent() && (otThreadGetDeviceRole(Inet::globalOtInstance) != OT_DEVICE_ROLE_DISABLED);
180+
}
181+
182+
InterfaceId InterfaceAddressIterator::GetInterfaceId()
183+
{
184+
// only 1 interface is supported
185+
return HasCurrent() ? InterfaceId(1) : InterfaceId::Null();
186+
}
187+
188+
bool InterfaceAddressIterator::HasBroadcastAddress()
189+
{
190+
return HasCurrent() && (otIp6GetMulticastAddresses(Inet::globalOtInstance) != nullptr);
191+
}
192+
158193
#endif
159194

160195
#if CHIP_SYSTEM_CONFIG_USE_LWIP && !CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT

src/inet/tests/TestInetAddress.cpp

+44-11
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535

3636
#include <inet/arpa-inet-compatibility.h>
3737

38+
#elif CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
39+
#include <inet/arpa-inet-compatibility.h>
40+
#include <openthread/icmp6.h>
41+
#include <openthread/ip6.h>
42+
3843
#else
3944
#include <netinet/in.h>
4045
#include <sys/socket.h>
@@ -718,12 +723,6 @@ void CheckAddress(nlTestSuite * inSuite, const IPAddressContext & inContext, con
718723

719724
CheckAddressQuartets(inSuite, inContext, inAddress);
720725

721-
// Convert the address to a string and compare it to the control string.
722-
723-
inAddress.ToString(lAddressBuffer);
724-
725-
CheckAddressString(inSuite, lAddressBuffer, inContext.mAddrString);
726-
727726
// Convert the control string to an address and compare the parsed address to the created address.
728727

729728
lResult = IPAddress::FromString(inContext.mAddrString, lParsedAddress);
@@ -735,6 +734,21 @@ void CheckAddress(nlTestSuite * inSuite, const IPAddressContext & inContext, con
735734
{
736735
fprintf(stdout, "Address parse mismatch for %s\n", inContext.mAddrString);
737736
}
737+
738+
// Convert the address to a string and compare it to the control string.
739+
740+
inAddress.ToString(lAddressBuffer);
741+
#if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
742+
// Embedded openthread stack otIp6AddressFromString format the string as a uncompressed IPV6
743+
// example ff01::1 is formatted has ff01:0:0:0:0:0:0:1
744+
// But the IPV6 address From string API (otIp6AddressFromString) handle both compressed and uncompressed format.
745+
char uncompressedAddrStr[INET6_ADDRSTRLEN];
746+
// Reconvert the previously parsed control string to an uncompressed string format
747+
lParsedAddress.ToString(uncompressedAddrStr);
748+
CheckAddressString(inSuite, lAddressBuffer, uncompressedAddrStr);
749+
#else
750+
CheckAddressString(inSuite, lAddressBuffer, inContext.mAddrString);
751+
#endif
738752
}
739753

740754
// Test functions invoked from the suite.
@@ -786,9 +800,22 @@ void CheckToString(nlTestSuite * inSuite, void * inContext)
786800
SetupIPAddress(lAddress, lCurrent);
787801

788802
lAddress.ToString(lAddressBuffer);
789-
803+
#if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
804+
// Embedded openthread stack otIp6AddressFromString format the string as a uncompressed IPV6
805+
// So ff01::1 is formatted has ff01:0:0:0:0:0:0:1
806+
// But the IPV6 address From string API (otIp6AddressFromString) handle both compressed and uncompressed format.
807+
// For this test, pass the expected, compressed, string throught the opentread stack address format API
808+
// so the final check evaluates uncompressed IPV6 strings.
809+
char uncompressedAddrStr[INET6_ADDRSTRLEN];
810+
IPAddress tempIpAddr;
811+
// Set Expected compressed IPV6 String as otIpv6 Address
812+
IPAddress::FromString(lCurrent->mAddr.mAddrString, strlen(lCurrent->mAddr.mAddrString), tempIpAddr);
813+
// Reconvert the expected IPV6 String to an uncompressed string format
814+
tempIpAddr.ToString(uncompressedAddrStr);
815+
CheckAddressString(inSuite, lAddressBuffer, uncompressedAddrStr);
816+
#else
790817
CheckAddressString(inSuite, lAddressBuffer, lCurrent->mAddr.mAddrString);
791-
818+
#endif // CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
792819
++lCurrent;
793820
}
794821
}
@@ -1015,6 +1042,9 @@ void CheckToIPv6(nlTestSuite * inSuite, void * inContext)
10151042
#if LWIP_IPV6_SCOPES
10161043
ip_addr_1.zone = 0;
10171044
#endif
1045+
#elif CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
1046+
otIp6Address ip_addr_1 = { 0 }, ip_addr_2 = { 0 };
1047+
memcpy(ip_addr_1.mFields.m32, addr, sizeof(addr));
10181048
#else
10191049
struct in6_addr ip_addr_1, ip_addr_2;
10201050
ip_addr_1 = *reinterpret_cast<struct in6_addr *>(addr);
@@ -1052,6 +1082,9 @@ void CheckFromIPv6(nlTestSuite * inSuite, void * inContext)
10521082
#if CHIP_SYSTEM_CONFIG_USE_LWIP
10531083
ip6_addr_t ip_addr;
10541084
memcpy(ip_addr.addr, addr, sizeof(addr));
1085+
#elif CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
1086+
otIp6Address ip_addr;
1087+
memcpy(ip_addr.mFields.m32, addr, sizeof(addr));
10551088
#else
10561089
struct in6_addr ip_addr;
10571090
ip_addr = *reinterpret_cast<struct in6_addr *>(addr);
@@ -1203,9 +1236,9 @@ void CheckFromIPv4(nlTestSuite * inSuite, void * inContext)
12031236
*/
12041237
void CheckFromSocket(nlTestSuite * inSuite, void * inContext)
12051238
{
1206-
#if CHIP_SYSTEM_CONFIG_USE_LWIP
1239+
#if CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
12071240
(void) inSuite;
1208-
// This test is only supported for non LWIP stack.
1241+
// This test is not supported LWIP or OPEN_THREAD_ENDPOINT stacks.
12091242
#else // CHIP_SYSTEM_CONFIG_USE_LWIP
12101243
const struct TestContext * lContext = static_cast<const struct TestContext *>(inContext);
12111244
IPAddressExpandedContextIterator lCurrent = lContext->mIPAddressExpandedContextRange.mBegin;
@@ -1261,7 +1294,7 @@ void CheckFromSocket(nlTestSuite * inSuite, void * inContext)
12611294

12621295
++lCurrent;
12631296
}
1264-
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
1297+
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
12651298
}
12661299

12671300
/**

src/lwip/BUILD.gn

-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ if (current_os == "zephyr" || current_os == "mbed") {
226226

227227
sources += [
228228
"${lwip_platform}/lwipopts-rs911x.h",
229-
"${lwip_platform}/lwipopts-thread.h",
230229
"${lwip_platform}/lwipopts-wf200.h",
231230
]
232231
} else if (lwip_platform == "standalone") {

src/lwip/silabs/lwipopts-thread.h

-182
This file was deleted.

src/lwip/silabs/lwipopts.h

-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22
#include "lwipopts-wf200.h"
33
#elif defined(RS911X_WIFI)
44
#include "lwipopts-rs911x.h"
5-
#else
6-
#include "lwipopts-thread.h"
75
#endif

src/test_driver/efr32/args.gni

-5
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,4 @@ chip_monolithic_tests = true
2929
openthread_external_platform =
3030
"${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32"
3131

32-
#Fix me : Test driver should use same config as examples
33-
# Problem : Linker issue if set to true
34-
chip_system_config_use_open_thread_inet_endpoints = false
35-
chip_with_lwip = true
36-
3732
pw_rpc_CONFIG = "$dir_pw_rpc:disable_global_mutex"

third_party/silabs/silabs_lwip/BUILD.gn

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ lwip_target("silabs_lwip") {
3636
sources = [
3737
"${chip_root}/src/lwip/freertos/sys_arch.c",
3838
"${chip_root}/src/lwip/silabs/lwipopts-rs911x.h",
39-
"${chip_root}/src/lwip/silabs/lwipopts-thread.h",
4039
"${chip_root}/src/lwip/silabs/lwipopts-wf200.h",
4140
]
4241

0 commit comments

Comments
 (0)