Skip to content

Commit

Permalink
Merge branch 'master' into esp32/enable_extended_ble_adv
Browse files Browse the repository at this point in the history
  • Loading branch information
sayondeep authored Mar 4, 2024
2 parents b87ad86 + c1ae85c commit bf0d913
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 202 deletions.
35 changes: 35 additions & 0 deletions src/inet/InetInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,23 @@ bool InterfaceIterator::Next()
return false;
}

CHIP_ERROR InterfaceIterator::GetInterfaceName(char * nameBuf, size_t nameBufSize)
{
VerifyOrReturnError(HasCurrent(), CHIP_ERROR_INCORRECT_STATE);
return InterfaceId(1).GetInterfaceName(nameBuf, nameBufSize);
}

InterfaceId InterfaceIterator::GetInterfaceId()
{
// only 1 interface is supported
return HasCurrent() ? InterfaceId(1) : InterfaceId::Null();
}

bool InterfaceIterator::IsUp()
{
return HasCurrent() && (otThreadGetDeviceRole(Inet::globalOtInstance) != OT_DEVICE_ROLE_DISABLED);
}

InterfaceAddressIterator::InterfaceAddressIterator()
{
mNetifAddrList = nullptr;
Expand All @@ -128,6 +145,8 @@ bool InterfaceAddressIterator::Next()
{
if (mNetifAddrList == nullptr)
{
if (Inet::globalOtInstance == nullptr)
return false;
mNetifAddrList = otIp6GetUnicastAddresses(Inet::globalOtInstance);
mCurAddr = mNetifAddrList;
}
Expand Down Expand Up @@ -155,6 +174,22 @@ uint8_t InterfaceAddressIterator::GetPrefixLength()
return 64;
}

bool InterfaceAddressIterator::IsUp()
{
return HasCurrent() && (otThreadGetDeviceRole(Inet::globalOtInstance) != OT_DEVICE_ROLE_DISABLED);
}

InterfaceId InterfaceAddressIterator::GetInterfaceId()
{
// only 1 interface is supported
return HasCurrent() ? InterfaceId(1) : InterfaceId::Null();
}

bool InterfaceAddressIterator::HasBroadcastAddress()
{
return HasCurrent() && (otIp6GetMulticastAddresses(Inet::globalOtInstance) != nullptr);
}

#endif

#if CHIP_SYSTEM_CONFIG_USE_LWIP && !CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
Expand Down
55 changes: 44 additions & 11 deletions src/inet/tests/TestInetAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@

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

#elif CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
#include <inet/arpa-inet-compatibility.h>
#include <openthread/icmp6.h>
#include <openthread/ip6.h>

#else
#include <netinet/in.h>
#include <sys/socket.h>
Expand Down Expand Up @@ -718,12 +723,6 @@ void CheckAddress(nlTestSuite * inSuite, const IPAddressContext & inContext, con

CheckAddressQuartets(inSuite, inContext, inAddress);

// Convert the address to a string and compare it to the control string.

inAddress.ToString(lAddressBuffer);

CheckAddressString(inSuite, lAddressBuffer, inContext.mAddrString);

// Convert the control string to an address and compare the parsed address to the created address.

lResult = IPAddress::FromString(inContext.mAddrString, lParsedAddress);
Expand All @@ -735,6 +734,21 @@ void CheckAddress(nlTestSuite * inSuite, const IPAddressContext & inContext, con
{
fprintf(stdout, "Address parse mismatch for %s\n", inContext.mAddrString);
}

// Convert the address to a string and compare it to the control string.

inAddress.ToString(lAddressBuffer);
#if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
// Embedded openthread stack otIp6AddressFromString format the string as a uncompressed IPV6
// example ff01::1 is formatted has ff01:0:0:0:0:0:0:1
// But the IPV6 address From string API (otIp6AddressFromString) handle both compressed and uncompressed format.
char uncompressedAddrStr[INET6_ADDRSTRLEN];
// Reconvert the previously parsed control string to an uncompressed string format
lParsedAddress.ToString(uncompressedAddrStr);
CheckAddressString(inSuite, lAddressBuffer, uncompressedAddrStr);
#else
CheckAddressString(inSuite, lAddressBuffer, inContext.mAddrString);
#endif
}

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

lAddress.ToString(lAddressBuffer);

#if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
// Embedded openthread stack otIp6AddressFromString format the string as a uncompressed IPV6
// So ff01::1 is formatted has ff01:0:0:0:0:0:0:1
// But the IPV6 address From string API (otIp6AddressFromString) handle both compressed and uncompressed format.
// For this test, pass the expected, compressed, string throught the opentread stack address format API
// so the final check evaluates uncompressed IPV6 strings.
char uncompressedAddrStr[INET6_ADDRSTRLEN];
IPAddress tempIpAddr;
// Set Expected compressed IPV6 String as otIpv6 Address
IPAddress::FromString(lCurrent->mAddr.mAddrString, strlen(lCurrent->mAddr.mAddrString), tempIpAddr);
// Reconvert the expected IPV6 String to an uncompressed string format
tempIpAddr.ToString(uncompressedAddrStr);
CheckAddressString(inSuite, lAddressBuffer, uncompressedAddrStr);
#else
CheckAddressString(inSuite, lAddressBuffer, lCurrent->mAddr.mAddrString);

#endif // CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
++lCurrent;
}
}
Expand Down Expand Up @@ -1015,6 +1042,9 @@ void CheckToIPv6(nlTestSuite * inSuite, void * inContext)
#if LWIP_IPV6_SCOPES
ip_addr_1.zone = 0;
#endif
#elif CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
otIp6Address ip_addr_1 = { 0 }, ip_addr_2 = { 0 };
memcpy(ip_addr_1.mFields.m32, addr, sizeof(addr));
#else
struct in6_addr ip_addr_1, ip_addr_2;
ip_addr_1 = *reinterpret_cast<struct in6_addr *>(addr);
Expand Down Expand Up @@ -1052,6 +1082,9 @@ void CheckFromIPv6(nlTestSuite * inSuite, void * inContext)
#if CHIP_SYSTEM_CONFIG_USE_LWIP
ip6_addr_t ip_addr;
memcpy(ip_addr.addr, addr, sizeof(addr));
#elif CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
otIp6Address ip_addr;
memcpy(ip_addr.mFields.m32, addr, sizeof(addr));
#else
struct in6_addr ip_addr;
ip_addr = *reinterpret_cast<struct in6_addr *>(addr);
Expand Down Expand Up @@ -1203,9 +1236,9 @@ void CheckFromIPv4(nlTestSuite * inSuite, void * inContext)
*/
void CheckFromSocket(nlTestSuite * inSuite, void * inContext)
{
#if CHIP_SYSTEM_CONFIG_USE_LWIP
#if CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
(void) inSuite;
// This test is only supported for non LWIP stack.
// This test is not supported LWIP or OPEN_THREAD_ENDPOINT stacks.
#else // CHIP_SYSTEM_CONFIG_USE_LWIP
const struct TestContext * lContext = static_cast<const struct TestContext *>(inContext);
IPAddressExpandedContextIterator lCurrent = lContext->mIPAddressExpandedContextRange.mBegin;
Expand Down Expand Up @@ -1261,7 +1294,7 @@ void CheckFromSocket(nlTestSuite * inSuite, void * inContext)

++lCurrent;
}
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/lwip/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ if (current_os == "zephyr" || current_os == "mbed") {

sources += [
"${lwip_platform}/lwipopts-rs911x.h",
"${lwip_platform}/lwipopts-thread.h",
"${lwip_platform}/lwipopts-wf200.h",
]
} else if (lwip_platform == "standalone") {
Expand Down
182 changes: 0 additions & 182 deletions src/lwip/silabs/lwipopts-thread.h

This file was deleted.

2 changes: 0 additions & 2 deletions src/lwip/silabs/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
#include "lwipopts-wf200.h"
#elif defined(RS911X_WIFI)
#include "lwipopts-rs911x.h"
#else
#include "lwipopts-thread.h"
#endif
5 changes: 0 additions & 5 deletions src/test_driver/efr32/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,4 @@ chip_monolithic_tests = true
openthread_external_platform =
"${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32"

#Fix me : Test driver should use same config as examples
# Problem : Linker issue if set to true
chip_system_config_use_open_thread_inet_endpoints = false
chip_with_lwip = true

pw_rpc_CONFIG = "$dir_pw_rpc:disable_global_mutex"
1 change: 0 additions & 1 deletion third_party/silabs/silabs_lwip/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ lwip_target("silabs_lwip") {
sources = [
"${chip_root}/src/lwip/freertos/sys_arch.c",
"${chip_root}/src/lwip/silabs/lwipopts-rs911x.h",
"${chip_root}/src/lwip/silabs/lwipopts-thread.h",
"${chip_root}/src/lwip/silabs/lwipopts-wf200.h",
]

Expand Down

0 comments on commit bf0d913

Please sign in to comment.