mirror of
https://github.com/espressif/openthread.git
synced 2026-06-06 05:24:51 +00:00
[mle] do not echo back ML-EID registered by MTD (#3640)
* do not echo back ML-EID registered by MTD * update the address registration check in Cert_7_1_01 and Cert_7_1_03
This commit is contained in:
@@ -126,6 +126,7 @@ enum
|
||||
kReedAdvertiseJitter = 60, ///< REED_ADVERTISEMENT_JITTER (sec)
|
||||
kLeaderWeight = 64, ///< Default leader weight
|
||||
kMleEndDeviceTimeout = OPENTHREAD_CONFIG_DEFAULT_CHILD_TIMEOUT, ///< MLE_END_DEVICE_TIMEOUT (sec)
|
||||
kMeshLocalPrefixContextId = 0, ///< 0 is reserved for Mesh Local Prefix
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -3327,7 +3327,7 @@ Neighbor *MleRouter::GetNeighbor(const Ip6::Address &aAddress)
|
||||
{
|
||||
child = iter.GetChild();
|
||||
|
||||
if (context.mContextId == 0 && aAddress.mFields.m16[4] == HostSwap16(0x0000) &&
|
||||
if (context.mContextId == kMeshLocalPrefixContextId && aAddress.mFields.m16[4] == HostSwap16(0x0000) &&
|
||||
aAddress.mFields.m16[5] == HostSwap16(0x00ff) && aAddress.mFields.m16[6] == HostSwap16(0xfe00) &&
|
||||
aAddress.mFields.m16[7] == HostSwap16(child->GetRloc16()))
|
||||
{
|
||||
@@ -3340,7 +3340,7 @@ Neighbor *MleRouter::GetNeighbor(const Ip6::Address &aAddress)
|
||||
}
|
||||
}
|
||||
|
||||
VerifyOrExit(context.mContextId == 0, rval = NULL);
|
||||
VerifyOrExit(context.mContextId == kMeshLocalPrefixContextId, rval = NULL);
|
||||
|
||||
if (aAddress.mFields.m16[4] == HostSwap16(0x0000) && aAddress.mFields.m16[5] == HostSwap16(0x00ff) &&
|
||||
aAddress.mFields.m16[6] == HostSwap16(0xfe00))
|
||||
@@ -4364,19 +4364,31 @@ otError MleRouter::AppendChildAddresses(Message &aMessage, Child &aChild)
|
||||
entry.SetUncompressed();
|
||||
entry.SetIp6Address(address);
|
||||
}
|
||||
else
|
||||
else if (context.mContextId != kMeshLocalPrefixContextId)
|
||||
{
|
||||
// compressed entry
|
||||
entry.SetContextId(context.mContextId);
|
||||
entry.SetIid(address.GetIid());
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
SuccessOrExit(error = aMessage.Append(&entry, entry.GetLength()));
|
||||
length += entry.GetLength();
|
||||
}
|
||||
|
||||
tlv.SetLength(length);
|
||||
aMessage.Write(startOffset, sizeof(tlv), &tlv);
|
||||
if (length > 0)
|
||||
{
|
||||
tlv.SetLength(length);
|
||||
aMessage.Write(startOffset, sizeof(tlv), &tlv);
|
||||
}
|
||||
else
|
||||
{
|
||||
// remove AddressRegistrationTlv if no address to be echoed back
|
||||
aMessage.SetLength(startOffset);
|
||||
}
|
||||
|
||||
exit:
|
||||
return error;
|
||||
|
||||
@@ -83,7 +83,7 @@ otError LeaderBase::GetContext(const Ip6::Address &aAddress, Lowpan::Context &aC
|
||||
{
|
||||
aContext.mPrefix = netif.GetMle().GetMeshLocalPrefix().m8;
|
||||
aContext.mPrefixLength = 64;
|
||||
aContext.mContextId = 0;
|
||||
aContext.mContextId = Mle::kMeshLocalPrefixContextId;
|
||||
aContext.mCompressFlag = true;
|
||||
}
|
||||
|
||||
@@ -127,11 +127,11 @@ otError LeaderBase::GetContext(uint8_t aContextId, Lowpan::Context &aContext)
|
||||
PrefixTlv * prefix;
|
||||
ContextTlv *contextTlv;
|
||||
|
||||
if (aContextId == 0)
|
||||
if (aContextId == Mle::kMeshLocalPrefixContextId)
|
||||
{
|
||||
aContext.mPrefix = GetNetif().GetMle().GetMeshLocalPrefix().m8;
|
||||
aContext.mPrefixLength = 64;
|
||||
aContext.mContextId = 0;
|
||||
aContext.mContextId = Mle::kMeshLocalPrefixContextId;
|
||||
aContext.mCompressFlag = true;
|
||||
ExitNow(error = OT_ERROR_NONE);
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ class Cert_5_2_5_AddressQuery(unittest.TestCase):
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
self.nodes[LEADER].add_prefix('2001::/64', 'pdros')
|
||||
self.nodes[LEADER].register_netdata()
|
||||
self.simulator.set_lowpan_context(1, '2001::/64')
|
||||
|
||||
# 2. BR: SLAAC Server for prefix 2002::/64.
|
||||
self.nodes[BR].start()
|
||||
@@ -93,6 +94,7 @@ class Cert_5_2_5_AddressQuery(unittest.TestCase):
|
||||
self.assertEqual(self.nodes[BR].get_state(), 'router')
|
||||
self.nodes[BR].add_prefix('2002::/64', 'paros')
|
||||
self.nodes[BR].register_netdata()
|
||||
self.simulator.set_lowpan_context(2, '2002::/64')
|
||||
|
||||
# 3. Bring up remaining devices except DUT_REED.
|
||||
for i in range(2, 17):
|
||||
|
||||
@@ -120,6 +120,9 @@ class Cert_5_3_7_DuplicateAddress(unittest.TestCase):
|
||||
self.nodes[ROUTER2].add_prefix('2001:2:0:1::/64', 'paros')
|
||||
self.nodes[ROUTER2].register_netdata()
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(1, '2001:2:0:1::/64')
|
||||
|
||||
self.nodes[MED1].add_ipaddr('2001:2:0:1::1234')
|
||||
self.nodes[SED1].add_ipaddr('2001:2:0:1::1234')
|
||||
|
||||
|
||||
@@ -86,6 +86,11 @@ class Cert_5_6_1_NetworkDataLeaderAsBr(unittest.TestCase):
|
||||
self.nodes[LEADER].add_prefix('2001:2:0:1::/64', 'paros')
|
||||
self.nodes[LEADER].add_prefix('2001:2:0:2::/64', 'paro')
|
||||
self.nodes[LEADER].register_netdata()
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(1, '2001:2:0:1::/64')
|
||||
self.simulator.set_lowpan_context(2, '2001:2:0:2::/64')
|
||||
|
||||
self.simulator.go(5)
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
|
||||
@@ -91,6 +91,10 @@ class Cert_5_6_2_NetworkDataRouterAsBr(unittest.TestCase):
|
||||
self.nodes[ROUTER].add_prefix('2001:2:0:2::/64', 'paro')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(1, '2001:2:0:1::/64')
|
||||
self.simulator.set_lowpan_context(2, '2001:2:0:2::/64')
|
||||
|
||||
self.nodes[ED1].start()
|
||||
self.simulator.go(5)
|
||||
self.assertEqual(self.nodes[ED1].get_state(), 'child')
|
||||
|
||||
@@ -99,6 +99,10 @@ class Cert_5_6_3_NetworkDataRegisterAfterAttachLeader(unittest.TestCase):
|
||||
self.nodes[LEADER].add_prefix('2001:2:0:2::/64', 'paro')
|
||||
self.nodes[LEADER].register_netdata()
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(1, '2001:2:0:1::/64')
|
||||
self.simulator.set_lowpan_context(2, '2001:2:0:2::/64')
|
||||
|
||||
self.simulator.go(10)
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
|
||||
@@ -99,6 +99,10 @@ class Cert_5_6_4_NetworkDataRegisterAfterAttachRouter(unittest.TestCase):
|
||||
self.nodes[ROUTER].add_prefix('2001:2:0:2::/64', 'paro')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(1, '2001:2:0:1::/64')
|
||||
self.simulator.set_lowpan_context(2, '2001:2:0:2::/64')
|
||||
|
||||
self.simulator.go(10)
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
|
||||
@@ -99,6 +99,10 @@ class Cert_5_6_5_NetworkDataRegisterAfterAttachRouter(unittest.TestCase):
|
||||
self.nodes[ROUTER].add_prefix('2001:2:0:2::/64', 'paro')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(1, '2001:2:0:1::/64')
|
||||
self.simulator.set_lowpan_context(2, '2001:2:0:2::/64')
|
||||
|
||||
self.simulator.go(10)
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
@@ -118,6 +122,9 @@ class Cert_5_6_5_NetworkDataRegisterAfterAttachRouter(unittest.TestCase):
|
||||
self.nodes[ROUTER].add_prefix('2001:2:0:3::/64', 'pacs')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(3, '2001:2:0:3::/64')
|
||||
|
||||
self.simulator.go(10)
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
|
||||
@@ -99,6 +99,10 @@ class Cert_5_6_6_NetworkDataExpiration(unittest.TestCase):
|
||||
self.nodes[ROUTER].add_prefix('2001:2:0:2::/64', 'paro')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(1, '2001:2:0:1::/64')
|
||||
self.simulator.set_lowpan_context(2, '2001:2:0:2::/64')
|
||||
|
||||
self.simulator.go(10)
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
@@ -118,6 +122,9 @@ class Cert_5_6_6_NetworkDataExpiration(unittest.TestCase):
|
||||
self.nodes[ROUTER].add_prefix('2001:2:0:3::/64', 'pacs')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(3, '2001:2:0:3::/64')
|
||||
|
||||
self.simulator.go(10)
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
|
||||
@@ -88,6 +88,9 @@ class Cert_5_6_7_NetworkDataRequestREED(unittest.TestCase):
|
||||
self.nodes[ROUTER].add_prefix('2001:2:0:3::/64', 'paros')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(1, '2001:2:0:3::/64')
|
||||
|
||||
self.simulator.go(2)
|
||||
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[REED].get_addr64())
|
||||
|
||||
@@ -84,6 +84,10 @@ class Cert_5_6_8_ContextManagement(unittest.TestCase):
|
||||
|
||||
self.nodes[ROUTER].add_prefix('2001:2:0:1::/64', 'paros')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(1, '2001:2:0:1::/64')
|
||||
|
||||
self.simulator.go(2)
|
||||
|
||||
addrs = self.nodes[LEADER].get_addrs()
|
||||
@@ -104,6 +108,10 @@ class Cert_5_6_8_ContextManagement(unittest.TestCase):
|
||||
|
||||
self.nodes[ROUTER].add_prefix('2001:2:0:2::/64', 'paros')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(2, '2001:2:0:2::/64')
|
||||
|
||||
self.simulator.go(5)
|
||||
|
||||
addrs = self.nodes[LEADER].get_addrs()
|
||||
@@ -116,6 +124,10 @@ class Cert_5_6_8_ContextManagement(unittest.TestCase):
|
||||
self.simulator.go(5)
|
||||
self.nodes[ROUTER].add_prefix('2001:2:0:3::/64', 'paros')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(3, '2001:2:0:3::/64')
|
||||
|
||||
self.simulator.go(5)
|
||||
|
||||
addrs = self.nodes[LEADER].get_addrs()
|
||||
|
||||
@@ -110,6 +110,10 @@ class Cert_5_6_9_NetworkDataForwarding(unittest.TestCase):
|
||||
self.nodes[LEADER].add_prefix('2001:2:0:1::/64', 'paros', 'med')
|
||||
self.nodes[LEADER].add_route('2001:2:0:2::/64', 'med')
|
||||
self.nodes[LEADER].register_netdata()
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(1, '2001:2:0:1::/64')
|
||||
|
||||
self.simulator.go(10)
|
||||
|
||||
self.nodes[ROUTER2].add_prefix('2001:2:0:1::/64', 'paros', 'low')
|
||||
|
||||
@@ -31,7 +31,7 @@ import unittest
|
||||
|
||||
from command import check_parent_request
|
||||
from command import check_child_id_request
|
||||
from command import check_child_update_request_by_child
|
||||
from command import check_child_update_request_from_child
|
||||
from command import CheckType
|
||||
import config
|
||||
import mle
|
||||
@@ -109,7 +109,7 @@ class Cert_6_1_2_REEDAttach_MED(unittest.TestCase):
|
||||
|
||||
# Step 8 - DUT sends Child Update messages
|
||||
msg = med_messages.next_mle_message(mle.CommandType.CHILD_UPDATE_REQUEST)
|
||||
check_child_update_request_by_child(msg)
|
||||
check_child_update_request_from_child(msg, source_address=CheckType.CONTAIN, leader_data=CheckType.CONTAIN)
|
||||
|
||||
# Step 10 - Leader sends ICMPv6 echo request, to DUT link local address
|
||||
med_addrs = self.nodes[MED].get_addrs()
|
||||
|
||||
@@ -72,6 +72,10 @@ class Cert_6_3_2_NetworkDataUpdate(unittest.TestCase):
|
||||
|
||||
self.nodes[LEADER].add_prefix('2001:2:0:1::/64', 'paros')
|
||||
self.nodes[LEADER].register_netdata()
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(1, '2001:2:0:1::/64')
|
||||
|
||||
self.simulator.go(5)
|
||||
|
||||
addrs = self.nodes[ED].get_addrs()
|
||||
@@ -85,6 +89,10 @@ class Cert_6_3_2_NetworkDataUpdate(unittest.TestCase):
|
||||
|
||||
self.nodes[LEADER].add_prefix('2001:2:0:2::/64', 'paros')
|
||||
self.nodes[LEADER].register_netdata()
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(2, '2001:2:0:2::/64')
|
||||
|
||||
self.simulator.go(5)
|
||||
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED].get_addr64())
|
||||
|
||||
@@ -33,8 +33,8 @@ import unittest
|
||||
|
||||
from command import check_child_id_response
|
||||
from command import check_child_update_response
|
||||
from command import check_child_update_request_from_child
|
||||
from command import check_data_response
|
||||
from command import check_message_address_registration_addr_set_equals
|
||||
from command import CheckType
|
||||
from command import NetworkDataCheckType
|
||||
import config
|
||||
@@ -96,6 +96,10 @@ class Cert_7_1_1_BorderRouterAsLeader(unittest.TestCase):
|
||||
self.nodes[LEADER].add_prefix('2001:2:0:2::/64', 'paro')
|
||||
self.nodes[LEADER].register_netdata()
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(1, '2001:2:0:1::/64')
|
||||
self.simulator.set_lowpan_context(2, '2001:2:0:2::/64')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
self.simulator.go(5)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
@@ -150,13 +154,14 @@ class Cert_7_1_1_BorderRouterAsLeader(unittest.TestCase):
|
||||
|
||||
# Step 10 - DUT sends Child Update Response
|
||||
msg_chd_upd_res_to_med = leader_messages.next_mle_message(mle.CommandType.CHILD_UPDATE_RESPONSE)
|
||||
check_child_update_response(msg_chd_upd_res_to_med, address_registration=CheckType.CONTAIN)
|
||||
msg = med1_messages.next_mle_message(mle.CommandType.CHILD_UPDATE_REQUEST)
|
||||
check_message_address_registration_addr_set_equals(msg, msg_chd_upd_res_to_med)
|
||||
check_child_update_request_from_child(msg, address_registration=CheckType.CONTAIN, CIDs=[0, 1, 2])
|
||||
|
||||
check_child_update_response(msg_chd_upd_res_to_med, address_registration=CheckType.CONTAIN, CIDs=[1, 2])
|
||||
|
||||
check_child_update_response(msg_chd_upd_res_to_sed, address_registration=CheckType.CONTAIN)
|
||||
msg = sed1_messages.next_mle_message(mle.CommandType.CHILD_UPDATE_REQUEST)
|
||||
check_message_address_registration_addr_set_equals(msg, msg_chd_upd_res_to_sed)
|
||||
check_child_update_request_from_child(msg, address_registration=CheckType.CONTAIN, CIDs=[0, 1])
|
||||
check_child_update_response(msg_chd_upd_res_to_sed, address_registration=CheckType.CONTAIN, CIDs=[1])
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
@@ -91,6 +91,10 @@ class Cert_7_1_2_BorderRouterAsRouter(unittest.TestCase):
|
||||
self.nodes[ROUTER].add_prefix('2001:2:0:2::/64', 'paro')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(1, '2001:2:0:1::/64')
|
||||
self.simulator.set_lowpan_context(2, '2001:2:0:2::/64')
|
||||
|
||||
self.nodes[ED2].start()
|
||||
self.simulator.go(5)
|
||||
self.assertEqual(self.nodes[ED2].get_state(), 'child')
|
||||
|
||||
@@ -112,6 +112,10 @@ class Cert_7_1_3_BorderRouterAsLeader(unittest.TestCase):
|
||||
self.nodes[LEADER].register_netdata()
|
||||
self.simulator.go(5)
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(1, '2001:2:0:1::/64')
|
||||
self.simulator.set_lowpan_context(2, '2001:2:0:2::/64')
|
||||
|
||||
leader_messages = self.simulator.get_messages_sent_by(LEADER)
|
||||
med1_messages = self.simulator.get_messages_sent_by(MED1)
|
||||
sed1_messages = self.simulator.get_messages_sent_by(SED1)
|
||||
@@ -138,15 +142,13 @@ class Cert_7_1_3_BorderRouterAsLeader(unittest.TestCase):
|
||||
# 4 - N/A
|
||||
# Get addresses registered by MED1
|
||||
msg = med1_messages.next_mle_message(mle.CommandType.CHILD_UPDATE_REQUEST)
|
||||
med1_addresses = msg.get_mle_message_tlv(mle.AddressRegistration).addresses
|
||||
command.check_child_update_request_from_child(msg, address_registration=CheckType.CONTAIN, CIDs=[0, 1, 2])
|
||||
|
||||
# 5 - Leader
|
||||
# Make a copy of leader's messages to ensure that we don't miss messages to SED1
|
||||
leader_messages_copy = leader_messages.clone()
|
||||
msg = leader_messages_copy.next_mle_message(mle.CommandType.CHILD_UPDATE_RESPONSE, sent_to_node=self.nodes[MED1])
|
||||
command.check_child_update_response(msg, address_registration=CheckType.CONTAIN)
|
||||
leader_addresses = msg.get_mle_message_tlv(mle.AddressRegistration).addresses
|
||||
self.assertTrue(all(addr in leader_addresses for addr in med1_addresses))
|
||||
command.check_child_update_response(msg, address_registration=CheckType.CONTAIN, CIDs=[1, 2])
|
||||
|
||||
# 6A & 6B - Leader
|
||||
if config.LEADER_NOTIFY_SED_BY_CHILD_UPDATE_REQUEST:
|
||||
@@ -160,13 +162,11 @@ class Cert_7_1_3_BorderRouterAsLeader(unittest.TestCase):
|
||||
# 7 - N/A
|
||||
# Get addresses registered by SED1
|
||||
msg = sed1_messages.next_mle_message(mle.CommandType.CHILD_UPDATE_REQUEST)
|
||||
sed1_addresses = msg.get_mle_message_tlv(mle.AddressRegistration).addresses
|
||||
command.check_child_update_request_from_child(msg, address_registration=CheckType.CONTAIN, CIDs=[0, 1])
|
||||
|
||||
# 8 - Leader
|
||||
msg = leader_messages.next_mle_message(mle.CommandType.CHILD_UPDATE_RESPONSE, sent_to_node=self.nodes[SED1])
|
||||
command.check_child_update_response(msg, address_registration=CheckType.CONTAIN)
|
||||
leader_addresses = msg.get_mle_message_tlv(mle.AddressRegistration).addresses
|
||||
self.assertTrue(all(addr in leader_addresses for addr in sed1_addresses))
|
||||
command.check_child_update_response(msg, address_registration=CheckType.CONTAIN, CIDs=[1])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -100,6 +100,10 @@ class Cert_7_1_4_BorderRouterAsRouter(unittest.TestCase):
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
self.simulator.go(5)
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(1, '2001:2:0:1::/64')
|
||||
self.simulator.set_lowpan_context(2, '2001:2:0:2::/64')
|
||||
|
||||
addrs = self.nodes[ED2].get_addrs()
|
||||
self.assertTrue(any('2001:2:0:1' in addr[0:10] for addr in addrs))
|
||||
self.assertTrue(any('2001:2:0:2' in addr[0:10] for addr in addrs))
|
||||
|
||||
@@ -100,6 +100,10 @@ class Cert_7_1_5_BorderRouterAsRouter(unittest.TestCase):
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
self.simulator.go(5)
|
||||
|
||||
# Set lowpan context of sniffer
|
||||
self.simulator.set_lowpan_context(1, '2001:2:0:1::/64')
|
||||
self.simulator.set_lowpan_context(2, '2001:2:0:2::/64')
|
||||
|
||||
addrs = self.nodes[ED2].get_addrs()
|
||||
self.assertTrue(any('2001:2:0:1' in addr[0:10] for addr in addrs))
|
||||
self.assertTrue(any('2001:2:0:2' in addr[0:10] for addr in addrs))
|
||||
|
||||
@@ -377,10 +377,22 @@ def check_prefix(prefix):
|
||||
assert contains_tlv(prefix.sub_tlvs, network_data.BorderRouter), 'Prefix doesn\'t contain a border router sub-TLV!'
|
||||
assert contains_tlv(prefix.sub_tlvs, network_data.LowpanId), 'Prefix doesn\'t contain a LowpanId sub-TLV!'
|
||||
|
||||
def check_child_update_request_by_child(command_msg):
|
||||
command_msg.assertMleMessageContainsTlv(mle.LeaderData)
|
||||
def check_child_update_request_from_child(command_msg, source_address=CheckType.OPTIONAL,
|
||||
leader_data=CheckType.OPTIONAL, challenge=CheckType.OPTIONAL, time_out=CheckType.OPTIONAL,
|
||||
address_registration=CheckType.OPTIONAL, tlv_request_tlv=CheckType.OPTIONAL,
|
||||
active_timestamp=CheckType.OPTIONAL, CIDs=[]):
|
||||
|
||||
command_msg.assertMleMessageContainsTlv(mle.Mode)
|
||||
command_msg.assertMleMessageContainsTlv(mle.SourceAddress)
|
||||
check_mle_optional_tlv(command_msg, source_address, mle.SourceAddress)
|
||||
check_mle_optional_tlv(command_msg, leader_data, mle.LeaderData)
|
||||
check_mle_optional_tlv(command_msg, challenge, mle.Challenge)
|
||||
check_mle_optional_tlv(command_msg, time_out, mle.Timeout)
|
||||
check_mle_optional_tlv(command_msg, address_registration, mle.AddressRegistration)
|
||||
check_mle_optional_tlv(command_msg, tlv_request_tlv, mle.TlvRequest)
|
||||
check_mle_optional_tlv(command_msg, active_timestamp, mle.ActiveTimestamp)
|
||||
|
||||
if (address_registration == CheckType.CONTAIN) and len(CIDs) > 0:
|
||||
_check_address_registration(command_msg, CIDs)
|
||||
|
||||
def check_coap_optional_tlv(coap_msg, type, tlv):
|
||||
if (type == CheckType.CONTAIN):
|
||||
@@ -445,7 +457,7 @@ def check_child_update_request_from_parent(command_msg, leader_data=CheckType.OP
|
||||
def check_child_update_response(command_msg, timeout=CheckType.OPTIONAL,
|
||||
address_registration=CheckType.OPTIONAL, address16=CheckType.OPTIONAL,
|
||||
leader_data=CheckType.OPTIONAL, network_data=CheckType.OPTIONAL, response=CheckType.OPTIONAL,
|
||||
link_layer_frame_counter=CheckType.OPTIONAL, mle_frame_counter=CheckType.OPTIONAL):
|
||||
link_layer_frame_counter=CheckType.OPTIONAL, mle_frame_counter=CheckType.OPTIONAL, CIDs=[]):
|
||||
"""Verify a properly formatted Child Update Response from parent
|
||||
"""
|
||||
check_secure_mle_key_id_mode(command_msg, 0x02)
|
||||
@@ -461,17 +473,19 @@ def check_child_update_response(command_msg, timeout=CheckType.OPTIONAL,
|
||||
check_mle_optional_tlv(command_msg, link_layer_frame_counter, mle.LinkLayerFrameCounter)
|
||||
check_mle_optional_tlv(command_msg, mle_frame_counter, mle.MleFrameCounter)
|
||||
|
||||
def unhashable_items_lists_equals(list1, list2):
|
||||
return all(item in list1 for item in list2) and all(item in list2 for item in list1)
|
||||
if (address_registration == CheckType.CONTAIN) and len(CIDs) > 0:
|
||||
_check_address_registration(command_msg, CIDs)
|
||||
|
||||
def check_message_address_registration_addr_set_equals(command_msg1, command_msg2):
|
||||
"""Verify that all addresses in the address set of AddressRegistration tlv in msg2
|
||||
are contained in that address set of AddressRegistration tlv in msg1
|
||||
"""
|
||||
addr_reg_tlv1 = command_msg1.assertMleMessageContainsTlv(mle.AddressRegistration)
|
||||
addr_reg_tlv2 = command_msg2.assertMleMessageContainsTlv(mle.AddressRegistration)
|
||||
# unordered lists comparison
|
||||
assert unhashable_items_lists_equals(addr_reg_tlv1.addresses, addr_reg_tlv2.addresses), 'Some addresses are not included in AddressRegistration TLV'
|
||||
def _check_address_registration(command_msg, CIDs=[]):
|
||||
addresses = command_msg.assertMleMessageContainsTlv(mle.AddressRegistration).addresses
|
||||
for cid in CIDs:
|
||||
found = False
|
||||
for address in addresses:
|
||||
if isinstance(address, mle.AddressCompressed):
|
||||
if cid == address.cid:
|
||||
found = True
|
||||
break
|
||||
assert found, "AddressRegistration TLV doesn't have CID {} ".format(cid)
|
||||
|
||||
def get_sub_tlv(tlvs, tlv_type):
|
||||
for sub_tlv in tlvs:
|
||||
|
||||
Reference in New Issue
Block a user