[network-data] add support for NAT64 flag in HasRoute TLV (#6429)

This commit adds a new flag in `NetworkData::HasRouteEntry` to
indicate that an off-mesh route prefix in the Network Data is also a
NAT64 prefix. It updates the public `otExternalRouteConfig` structure
to include `mNat64` bit flag and adds support for it in the core
modules.

It also updates `test_network_data` unit test to cover the new flag
and also adds some smaller style changes in this test.

This commit updates the CLI modules to add support for the new
flag. It also adds smaller enhancements in CLI related to network
data, adding methods `NetworkData::OutputPreference()` and
`OutputIp6Prefix()` to output common info (shared between on-mesh
prefixes and off-mesh routes), also simplifying how the flags are
mapped to char array string (avoiding extra space char in the output
string).

This commit also updates spinel and NCP code to add support for the
new NAT64 flag.
This commit is contained in:
Abtin Keshavarzian
2021-04-21 22:19:27 -07:00
committed by GitHub
parent 6fa74b7674
commit f4344792da
14 changed files with 274 additions and 112 deletions
+91 -44
View File
@@ -47,8 +47,8 @@ void PrintExternalRouteConfig(const ExternalRouteConfig &aConfig)
printf("%02x", b);
}
printf(", length:%d, rloc16:%04x, preference:%d, stable:%d, nexthop:%d", aConfig.mPrefix.mLength, aConfig.mRloc16,
aConfig.mPreference, aConfig.mStable, aConfig.mNextHopIsThisDevice);
printf(", length:%d, rloc16:%04x, preference:%d, nat64:%d, stable:%d, nexthop:%d", aConfig.mPrefix.mLength,
aConfig.mRloc16, aConfig.mPreference, aConfig.mNat64, aConfig.mStable, aConfig.mNextHopIsThisDevice);
}
// Returns true if the two given ExternalRouteConfig match (intentionally ignoring mNextHopIsThisDevice).
@@ -81,27 +81,37 @@ void TestNetworkDataIterator(void)
VerifyOrQuit(instance != nullptr, "Null OpenThread instance\n");
{
const uint8_t kNetworkData[] = {0x08, 0x04, 0x0B, 0x02, 0x00, 0x00, 0x03, 0x14, 0x00, 0x40,
0xFD, 0x00, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
0xC8, 0x00, 0x40, 0x01, 0x03, 0x54, 0x00, 0x00};
const uint8_t kNetworkData[] = {
0x08, 0x04, 0x0B, 0x02, 0x00, 0x00, 0x03, 0x14, 0x00, 0x40, 0xFD, 0x00, 0x12, 0x34,
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC8, 0x00, 0x40, 0x01, 0x03, 0x54, 0x00, 0x00,
};
otExternalRouteConfig routes[] = {
{
{{{{0xfd, 0x00, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
64},
0xc800,
1,
false,
false,
{
{{{0xfd, 0x00, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00}}},
64,
},
0xc800, // mRloc16
1, // mPreference
false, // mNat64
false, // mStable
false, // mNextHopIsThisDevice
},
{
{{{{0xfd, 0x00, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
64},
0x5400,
0,
true,
false,
}};
{
{{{0xfd, 0x00, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00}}},
64,
},
0x5400, // mRloc16
0, // mPreference
false, // mNat64
true, // mStable
false, // mNextHopIsThisDevice
},
};
TestNetworkData netData(instance, kNetworkData, sizeof(kNetworkData));
@@ -124,34 +134,71 @@ void TestNetworkDataIterator(void)
0x08, 0x04, 0x0B, 0x02, 0x00, 0x00, 0x03, 0x1E, 0x00, 0x40, 0xFD, 0x00, 0x12, 0x34, 0x56, 0x78, 0x00, 0x00,
0x07, 0x02, 0x11, 0x40, 0x00, 0x03, 0x10, 0x00, 0x40, 0x01, 0x03, 0x54, 0x00, 0x00, 0x05, 0x04, 0x54, 0x00,
0x31, 0x00, 0x02, 0x0F, 0x00, 0x40, 0xFD, 0x00, 0xAB, 0xBA, 0xCD, 0xDC, 0x00, 0x00, 0x00, 0x03, 0x10, 0x00,
0x00, 0x03, 0x0E, 0x00, 0x20, 0xFD, 0x00, 0xAB, 0xBA, 0x01, 0x06, 0x54, 0x00, 0x00, 0x04, 0x00, 0x00};
0x20, 0x03, 0x0E, 0x00, 0x20, 0xFD, 0x00, 0xAB, 0xBA, 0x01, 0x06, 0x54, 0x00, 0x00, 0x04, 0x00, 0x00,
};
otExternalRouteConfig routes[] = {
{{{{{0xfd, 0x00, 0x12, 0x34, 0x56, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, 64},
0x1000,
1,
false,
false},
{{{{{0xfd, 0x00, 0x12, 0x34, 0x56, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, 64},
0x5400,
0,
true,
false},
{{{{{0xfd, 0x00, 0xab, 0xba, 0xcd, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, 64},
0x1000,
0,
false,
false},
{{{{{0xfd, 0x00, 0xab, 0xba, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, 32},
0x5400,
0,
true,
false},
{{{{{0xfd, 0x00, 0xab, 0xba, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, 32},
0x0400,
0,
true,
false}};
{
{
{{{0xfd, 0x00, 0x12, 0x34, 0x56, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00}}},
64,
},
0x1000, // mRloc16
1, // mPreference
false, // mNat64
false, // mStable
false, // mNextHopIsThisDevice
},
{
{
{{{0xfd, 0x00, 0x12, 0x34, 0x56, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00}}},
64,
},
0x5400, // mRloc16
0, // mPreference
false, // mNat64
true, // mStable
false, // mNextHopIsThisDevice
},
{
{
{{{0xfd, 0x00, 0xab, 0xba, 0xcd, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00}}},
64,
},
0x1000, // mRloc16
0, // mPreference
true, // mNat64
false, // mStable
false, // mNextHopIsThisDevice
},
{
{
{{{0xfd, 0x00, 0xab, 0xba, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00}}},
32,
},
0x5400, // mRloc16
0, // mPreference
false, // mNat64
true, // mStable
false, // mNextHopIsThisDevice
},
{
{
{{{0xfd, 0x00, 0xab, 0xba, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00}}},
32,
},
0x0400, // mRloc16
0, // mPreference
false, // mNat64
true, // mStable
false, // mNextHopIsThisDevice
},
};
TestNetworkData netData(instance, kNetworkData, sizeof(kNetworkData));