35
35
36
36
#include < inet/arpa-inet-compatibility.h>
37
37
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
+
38
43
#else
39
44
#include < netinet/in.h>
40
45
#include < sys/socket.h>
@@ -718,12 +723,6 @@ void CheckAddress(nlTestSuite * inSuite, const IPAddressContext & inContext, con
718
723
719
724
CheckAddressQuartets (inSuite, inContext, inAddress);
720
725
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
-
727
726
// Convert the control string to an address and compare the parsed address to the created address.
728
727
729
728
lResult = IPAddress::FromString (inContext.mAddrString , lParsedAddress);
@@ -735,6 +734,21 @@ void CheckAddress(nlTestSuite * inSuite, const IPAddressContext & inContext, con
735
734
{
736
735
fprintf (stdout, " Address parse mismatch for %s\n " , inContext.mAddrString );
737
736
}
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
738
752
}
739
753
740
754
// Test functions invoked from the suite.
@@ -786,9 +800,22 @@ void CheckToString(nlTestSuite * inSuite, void * inContext)
786
800
SetupIPAddress (lAddress, lCurrent);
787
801
788
802
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
790
817
CheckAddressString (inSuite, lAddressBuffer, lCurrent->mAddr .mAddrString );
791
-
818
+ # endif // CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
792
819
++lCurrent;
793
820
}
794
821
}
@@ -1015,6 +1042,9 @@ void CheckToIPv6(nlTestSuite * inSuite, void * inContext)
1015
1042
#if LWIP_IPV6_SCOPES
1016
1043
ip_addr_1.zone = 0 ;
1017
1044
#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));
1018
1048
#else
1019
1049
struct in6_addr ip_addr_1, ip_addr_2;
1020
1050
ip_addr_1 = *reinterpret_cast <struct in6_addr *>(addr);
@@ -1052,6 +1082,9 @@ void CheckFromIPv6(nlTestSuite * inSuite, void * inContext)
1052
1082
#if CHIP_SYSTEM_CONFIG_USE_LWIP
1053
1083
ip6_addr_t ip_addr;
1054
1084
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));
1055
1088
#else
1056
1089
struct in6_addr ip_addr;
1057
1090
ip_addr = *reinterpret_cast <struct in6_addr *>(addr);
@@ -1203,9 +1236,9 @@ void CheckFromIPv4(nlTestSuite * inSuite, void * inContext)
1203
1236
*/
1204
1237
void CheckFromSocket (nlTestSuite * inSuite, void * inContext)
1205
1238
{
1206
- #if CHIP_SYSTEM_CONFIG_USE_LWIP
1239
+ #if CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
1207
1240
(void ) inSuite;
1208
- // This test is only supported for non LWIP stack .
1241
+ // This test is not supported LWIP or OPEN_THREAD_ENDPOINT stacks .
1209
1242
#else // CHIP_SYSTEM_CONFIG_USE_LWIP
1210
1243
const struct TestContext * lContext = static_cast <const struct TestContext *>(inContext);
1211
1244
IPAddressExpandedContextIterator lCurrent = lContext->mIPAddressExpandedContextRange .mBegin ;
@@ -1261,7 +1294,7 @@ void CheckFromSocket(nlTestSuite * inSuite, void * inContext)
1261
1294
1262
1295
++lCurrent;
1263
1296
}
1264
- #endif // CHIP_SYSTEM_CONFIG_USE_LWIP
1297
+ #endif // CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
1265
1298
}
1266
1299
1267
1300
/* *
0 commit comments